Re: [PATCH] [libstdc++-v3] [rtems] enable filesystem support

2024-07-27 Thread Alexandre Oliva
Hello, Jonathan,

ISTM I've failed to answer, sorry

On May 30, 2024, Jonathan Wakely  wrote:

> I got bounces from oarcorp.com and rtems.org, are the details in
> MAINTAINERS out of date for Joel and Ralf?

I got bounces as well back then.  I don't know whether this means the
addresses were outdated or temporarily unusable.

-- 
Alexandre Oliva, happy hackerhttps://FSFLA.org/blogs/lxo/
   Free Software Activist   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive


[PATCH] LoongArch: Use iorn and andn standard pattern names for scalar modes.

2024-07-27 Thread Lulu Cheng
gcc/ChangeLog:

* config/loongarch/loongarch.md (n): Rename to ...
(n3): This.
---
 gcc/config/loongarch/loongarch.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/loongarch/loongarch.md 
b/gcc/config/loongarch/loongarch.md
index 459ad30b9bb..4e4ddd515c9 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -1668,7 +1668,7 @@ (define_insn "*norsi3_internal"
   [(set_attr "type" "logical")
(set_attr "mode" "SI")])
 
-(define_insn "n"
+(define_insn "n3"
   [(set (match_operand:X 0 "register_operand" "=r")
(neg_bitwise:X
(not:X (match_operand:X 1 "register_operand" "r"))
-- 
2.39.3



Re: [PATCH] LoongArch: Use iorn and andn standard pattern names for scalar modes.

2024-07-27 Thread Xi Ruoyao
On Sat, 2024-07-27 at 16:36 +0800, Lulu Cheng wrote:
> gcc/ChangeLog:
> 
>   * config/loongarch/loongarch.md (n): Rename to ...
>   (n3): This.

Ok.

Note that [x]vorn3 and [x]vandn3 should be renamed as well.

> ---
>  gcc/config/loongarch/loongarch.md | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/config/loongarch/loongarch.md 
> b/gcc/config/loongarch/loongarch.md
> index 459ad30b9bb..4e4ddd515c9 100644
> --- a/gcc/config/loongarch/loongarch.md
> +++ b/gcc/config/loongarch/loongarch.md
> @@ -1668,7 +1668,7 @@ (define_insn "*norsi3_internal"
>    [(set_attr "type" "logical")
>     (set_attr "mode" "SI")])
>  
> -(define_insn "n"
> +(define_insn "n3"
>    [(set (match_operand:X 0 "register_operand" "=r")
>   (neg_bitwise:X
>       (not:X (match_operand:X 1 "register_operand" "r"))

-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University


Re: [PATCH] LoongArch: Use iorn and andn standard pattern names for scalar modes.

2024-07-27 Thread Lulu Cheng



在 2024/7/27 下午4:41, Xi Ruoyao 写道:

On Sat, 2024-07-27 at 16:36 +0800, Lulu Cheng wrote:

gcc/ChangeLog:

* config/loongarch/loongarch.md (n): Rename to ...
(n3): This.

Ok.

Note that [x]vorn3 and [x]vandn3 should be renamed as well.


Uh, I just forgot about them, I'm modifying the content of the vector.

Thanks!




---
  gcc/config/loongarch/loongarch.md | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/loongarch/loongarch.md 
b/gcc/config/loongarch/loongarch.md
index 459ad30b9bb..4e4ddd515c9 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -1668,7 +1668,7 @@ (define_insn "*norsi3_internal"
    [(set_attr "type" "logical")
     (set_attr "mode" "SI")])
  
-(define_insn "n"

+(define_insn "n3"
    [(set (match_operand:X 0 "register_operand" "=r")
    (neg_bitwise:X
        (not:X (match_operand:X 1 "register_operand" "r"))




[PATCH] LoongArch: Use iorn and andn standard pattern names for scalar modes.

2024-07-27 Thread Lulu Cheng
gcc/ChangeLog:

* config/loongarch/loongarch.md (n): Rename to ...
(n3): This.
---
 gcc/config/loongarch/loongarch.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/loongarch/loongarch.md 
b/gcc/config/loongarch/loongarch.md
index 459ad30b9bb..4e4ddd515c9 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -1668,7 +1668,7 @@ (define_insn "*norsi3_internal"
   [(set_attr "type" "logical")
(set_attr "mode" "SI")])
 
-(define_insn "n"
+(define_insn "n3"
   [(set (match_operand:X 0 "register_operand" "=r")
(neg_bitwise:X
(not:X (match_operand:X 1 "register_operand" "r"))
-- 
2.39.3



[PATCH] LoongArch: Use iorn and andn standard pattern names.

2024-07-27 Thread Lulu Cheng
gcc/ChangeLog:

* config/loongarch/lasx.md (xvandn3): Rename to ...
(andn3): This.
(xvorn3): Rename to ...
(iorn3): This.
* config/loongarch/loongarch-builtins.cc (CODE_FOR_lsx_vandn_v):
Defined as the modified name.
(CODE_FOR_lsx_vorn_v): Likewise.
(CODE_FOR_lasx_xvandn_v): Likewise.
(CODE_FOR_lasx_xvorn_v): Likewise.
* config/loongarch/loongarch.md (n): Rename to ...
(n3): This.
* config/loongarch/lsx.md (vandn3): Rename to ...
(andn3): This.
(vorn3): Rename to ...
(iorn3): This.
---
 gcc/config/loongarch/lasx.md   | 4 ++--
 gcc/config/loongarch/loongarch-builtins.cc | 8 
 gcc/config/loongarch/loongarch.md  | 2 +-
 gcc/config/loongarch/lsx.md| 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/config/loongarch/lasx.md b/gcc/config/loongarch/lasx.md
index 7bd61f8ed5b..c5fe04de86c 100644
--- a/gcc/config/loongarch/lasx.md
+++ b/gcc/config/loongarch/lasx.md
@@ -2716,7 +2716,7 @@ (define_insn "lasx_vext2xv_d_b"
(set_attr "mode" "V4DI")])
 
 ;; Extend loongson-sx to loongson-asx.
-(define_insn "xvandn3"
+(define_insn "andn3"
   [(set (match_operand:LASX 0 "register_operand" "=f")
(and:LASX (not:LASX (match_operand:LASX 1 "register_operand" "f"))
(match_operand:LASX 2 "register_operand" "f")))]
@@ -4637,7 +4637,7 @@ (define_insn "lasx_xvssrlrn__"
   [(set_attr "type" "simd_int_arith")
(set_attr "mode" "")])
 
-(define_insn "xvorn3"
+(define_insn "iorn3"
   [(set (match_operand:ILASX 0 "register_operand" "=f")
(ior:ILASX (not:ILASX (match_operand:ILASX 2 "register_operand" "f"))
   (match_operand:ILASX 1 "register_operand" "f")))]
diff --git a/gcc/config/loongarch/loongarch-builtins.cc 
b/gcc/config/loongarch/loongarch-builtins.cc
index fbe46833c9b..f0de80d767b 100644
--- a/gcc/config/loongarch/loongarch-builtins.cc
+++ b/gcc/config/loongarch/loongarch-builtins.cc
@@ -458,8 +458,8 @@ AVAIL_ALL (lasx_frecipe, ISA_HAS_LASX && ISA_HAS_FRECIPE)
 #define CODE_FOR_lsx_vabsd_du CODE_FOR_lsx_vabsd_u_du
 #define CODE_FOR_lsx_vftint_wu_s CODE_FOR_lsx_vftint_u_wu_s
 #define CODE_FOR_lsx_vftint_lu_d CODE_FOR_lsx_vftint_u_lu_d
-#define CODE_FOR_lsx_vandn_v CODE_FOR_vandnv16qi3
-#define CODE_FOR_lsx_vorn_v CODE_FOR_vornv16qi3
+#define CODE_FOR_lsx_vandn_v CODE_FOR_andnv16qi3
+#define CODE_FOR_lsx_vorn_v CODE_FOR_iornv16qi3
 #define CODE_FOR_lsx_vneg_b CODE_FOR_vnegv16qi2
 #define CODE_FOR_lsx_vneg_h CODE_FOR_vnegv8hi2
 #define CODE_FOR_lsx_vneg_w CODE_FOR_vnegv4si2
@@ -692,8 +692,8 @@ AVAIL_ALL (lasx_frecipe, ISA_HAS_LASX && ISA_HAS_FRECIPE)
 #define CODE_FOR_lasx_xvrepli_w CODE_FOR_lasx_xvrepliv8si
 #define CODE_FOR_lasx_xvrepli_d CODE_FOR_lasx_xvrepliv4di
 
-#define CODE_FOR_lasx_xvandn_v CODE_FOR_xvandnv32qi3
-#define CODE_FOR_lasx_xvorn_v CODE_FOR_xvornv32qi3
+#define CODE_FOR_lasx_xvandn_v CODE_FOR_andnv32qi3
+#define CODE_FOR_lasx_xvorn_v CODE_FOR_iornv32qi3
 #define CODE_FOR_lasx_xvneg_b CODE_FOR_negv32qi2
 #define CODE_FOR_lasx_xvneg_h CODE_FOR_negv16hi2
 #define CODE_FOR_lasx_xvneg_w CODE_FOR_negv8si2
diff --git a/gcc/config/loongarch/loongarch.md 
b/gcc/config/loongarch/loongarch.md
index 459ad30b9bb..4e4ddd515c9 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -1668,7 +1668,7 @@ (define_insn "*norsi3_internal"
   [(set_attr "type" "logical")
(set_attr "mode" "SI")])
 
-(define_insn "n"
+(define_insn "n3"
   [(set (match_operand:X 0 "register_operand" "=r")
(neg_bitwise:X
(not:X (match_operand:X 1 "register_operand" "r"))
diff --git a/gcc/config/loongarch/lsx.md b/gcc/config/loongarch/lsx.md
index 454cda47876..dcb667a6ce5 100644
--- a/gcc/config/loongarch/lsx.md
+++ b/gcc/config/loongarch/lsx.md
@@ -2344,7 +2344,7 @@ (define_insn_and_split "vec_concatv4sf"
 }
   [(set_attr "mode" "V4SF")])
 
-(define_insn "vandn3"
+(define_insn "andn3"
   [(set (match_operand:LSX 0 "register_operand" "=f")
(and:LSX (not:LSX (match_operand:LSX 1 "register_operand" "f"))
 (match_operand:LSX 2 "register_operand" "f")))]
@@ -3028,7 +3028,7 @@ (define_insn "lsx_vssrlrn__"
   [(set_attr "type" "simd_int_arith")
(set_attr "mode" "")])
 
-(define_insn "vorn3"
+(define_insn "iorn3"
   [(set (match_operand:ILSX 0 "register_operand" "=f")
(ior:ILSX (not:ILSX (match_operand:ILSX 2 "register_operand" "f"))
  (match_operand:ILSX 1 "register_operand" "f")))]
-- 
2.39.3



[Patch, fortran] PR79685 - [12/13/14/15 Regression] ICE on valid code in gfc_match_structure_constructor

2024-07-27 Thread Paul Richard Thomas
This patch is straightforward but I am still puzzled as to why it is
necessary for the particular case. Having looked at all the other chunks of
frontend code involving use renaming, it seems that the process just works
everywhere else. I tried putting the new code in gfc_find_symtree but it
caused some regressions unless I pinned it down to the specific case of a
structure constructor.

OK for mainline and backporting at a later date?

Paul

Fortran: Fix ICE with structure constructor in data statement [PR79685]

2024-07-27  Paul Thomas  

gcc/fortran
PR fortran/79685
* primary.cc (gfc_match_structure_constructor): See if there is
a use renamed symtree before calling gfc_get_ha_sym_tree. If so
use it.

gcc/testsuite/
PR fortran/79685
* gfortran.dg/use_rename_12.f90: New test.
diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index 76f6bcb8a78..30ea01961a3 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -3524,14 +3524,33 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result)
 {
   match m;
   gfc_expr *e;
-  gfc_symtree *symtree;
+  gfc_symtree *symtree = NULL;
   bool t = true;
+  gfc_use_list *use_stmts = gfc_current_ns->use_stmts;
 
-  gfc_get_ha_sym_tree (sym->name, &symtree);
+  /* Check if we have a usable symtree that is use renamed.  */
+  for (; use_stmts; use_stmts = use_stmts->next)
+{
+  if (!use_stmts->rename || use_stmts->rename->use_name[0] == 0)
+	continue;
+
+  if (!strcmp (use_stmts->rename->use_name, sym->name))
+	{
+	  symtree = gfc_find_symtree (gfc_current_ns->sym_root,
+  use_stmts->rename->local_name);
+	  if (symtree && symtree->name[0] != 0
+	  && symtree->n.sym->attr.flavor == FL_PROCEDURE)
+	break;
+	}
+}
+
+  /* Otherwise find or create the symtree.  */
+  if (!symtree)
+gfc_get_ha_sym_tree (sym->name, &symtree);
 
   e = gfc_get_expr ();
-  e->symtree = symtree;
   e->expr_type = EXPR_FUNCTION;
+  e->symtree = symtree;
   e->where = gfc_current_locus;
 
   gcc_assert (gfc_fl_struct (sym->attr.flavor)
diff --git a/gcc/testsuite/gfortran.dg/use_rename_12.f90 b/gcc/testsuite/gfortran.dg/use_rename_12.f90
new file mode 100644
index 000..97f26f42f76
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/use_rename_12.f90
@@ -0,0 +1,37 @@
+! { dg-do compile }
+!
+! Test the fix for pr79685, which failed as in the comments below.
+!
+! Contributed by Juergen Reuter  
+!
+module omega_color
+  implicit none
+
+  type omega_color_factor
+ integer :: i
+  end type
+
+  type(omega_color_factor), parameter :: op = omega_color_factor (199)
+
+end module
+
+module foo
+  use omega_color, ocf => omega_color_factor, ocfp => op
+  implicit none
+
+  type(ocf) :: table_color_factors1 = ocf(42)
+  type(ocf) :: table_color_factors2
+  type(ocf) :: table_color_factors3 (2)
+  type(ocf) :: table_color_factors4
+  data table_color_factors2 / ocf(99) /! This failed in gfc_match_structure_constructor.
+  data table_color_factors3 / ocf(1), ocf(2) / ! ditto.
+  data table_color_factors4 / ocfp /
+end module
+
+  use foo
+  if (table_color_factors1%i .ne. 42) stop 1
+  if (table_color_factors2%i .ne. 99) stop 2
+  if (any (table_color_factors3%i .ne. [1,2])) stop 3
+  if (table_color_factors4%i .ne. 199) stop 4
+end
+


Re: *** SPAM *** [Patch, fortran] PR79685 - [12/13/14/15 Regression] ICE on valid code in gfc_match_structure_constructor

2024-07-27 Thread Mikael Morin

Hello,

Le 27/07/2024 à 11:25, Paul Richard Thomas a écrit :
This patch is straightforward but I am still puzzled as to why it is 
necessary for the particular case. Having looked at all the other chunks 
of frontend code involving use renaming, it seems that the process just 
works everywhere else. I tried putting the new code in gfc_find_symtree 
but it caused some regressions unless I pinned it down to the specific 
case of a structure constructor.


I think it works as expected, symtrees have the local names, and symbols 
the original name, so if all that is available is the symbol, name 
lookup may not work correctly with renaming.  And I think that there are 
other places where it happens.


In this case, it seems the caller can provide the local name, which 
would avoid processing the use statements.  Did you try that?


Mikael


[committed] libstdc++: Remove __find_if unrolling for random access iterators

2024-07-27 Thread Jonathan Wakely
Tested x86_64-linux. Pushed to trunk.

-- >8 --

As the numbers in PR libstdc++/88545 show, the manual loop unrolling in
std::__find_if doesn't actually help these days, and it prevents the
compiler from auto-vectorizing.

Remove the dispatching on iterator_category and just use the simple loop
for all iterator categories.

libstdc++-v3/ChangeLog:

* include/bits/stl_algobase.h (__find_if): Remove overloads for
dispatching on iterator_category. Do not unroll loop manually.
* include/bits/stl_algo.h (__find_if_not): Remove
iterator_category argument from __find_if call.
---
 libstdc++-v3/include/bits/stl_algo.h |  3 +-
 libstdc++-v3/include/bits/stl_algobase.h | 70 ++--
 2 files changed, 5 insertions(+), 68 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_algo.h 
b/libstdc++-v3/include/bits/stl_algo.h
index d250b2e04d4..541f53b 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -110,8 +110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  _Predicate __pred)
 {
   return std::__find_if(__first, __last,
-   __gnu_cxx::__ops::__negate(__pred),
-   std::__iterator_category(__first));
+   __gnu_cxx::__ops::__negate(__pred));
 }
 
   /// Like find_if_not(), but uses and updates a count of the
diff --git a/libstdc++-v3/include/bits/stl_algobase.h 
b/libstdc++-v3/include/bits/stl_algobase.h
index dec1e4c79d8..27f6c377ad6 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -2098,77 +2098,15 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
 
 _GLIBCXX_END_NAMESPACE_ALGO
 
-  /// This is an overload used by find algos for the Input Iterator case.
-  template
-_GLIBCXX20_CONSTEXPR
-inline _InputIterator
-__find_if(_InputIterator __first, _InputIterator __last,
- _Predicate __pred, input_iterator_tag)
-{
-  while (__first != __last && !__pred(__first))
-   ++__first;
-  return __first;
-}
-
-  /// This is an overload used by find algos for the RAI case.
-  template
-_GLIBCXX20_CONSTEXPR
-_RandomAccessIterator
-__find_if(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Predicate __pred, random_access_iterator_tag)
-{
-  typename iterator_traits<_RandomAccessIterator>::difference_type
-   __trip_count = (__last - __first) >> 2;
-
-  for (; __trip_count > 0; --__trip_count)
-   {
- if (__pred(__first))
-   return __first;
- ++__first;
-
- if (__pred(__first))
-   return __first;
- ++__first;
-
- if (__pred(__first))
-   return __first;
- ++__first;
-
- if (__pred(__first))
-   return __first;
- ++__first;
-   }
-
-  switch (__last - __first)
-   {
-   case 3:
- if (__pred(__first))
-   return __first;
- ++__first;
- // FALLTHRU
-   case 2:
- if (__pred(__first))
-   return __first;
- ++__first;
- // FALLTHRU
-   case 1:
- if (__pred(__first))
-   return __first;
- ++__first;
- // FALLTHRU
-   case 0:
-   default:
- return __last;
-   }
-}
-
+  // Implementation of std::find_if, also used in std::remove_if and others.
   template
 _GLIBCXX20_CONSTEXPR
 inline _Iterator
 __find_if(_Iterator __first, _Iterator __last, _Predicate __pred)
 {
-  return __find_if(__first, __last, __pred,
-  std::__iterator_category(__first));
+  while (__first != __last && !__pred(__first))
+   ++__first;
+  return __first;
 }
 
   template
-- 
2.45.2



[committed] libstdc++: Fix -Wsign-compare warning in

2024-07-27 Thread Jonathan Wakely
Tested x86_64-linux. Pushed to trunk.

-- >8 --

Cast ptrdiff_t to size_t to avoid a -Wsign-compare warning. We can check
in __to_chars_i that the ptrdiff_t won't be negative, so that we know
the cast is safe.

libstdc++-v3/ChangeLog:

* include/std/charconv (__to_chars_16, __to_chars_10)
(__to_chars_8, __to_chars_2, __to_chars): Cast ptrdiff_t to
size_t for comparison.
(__to_chars_i): Check for first >= last instead of first == last
for initial sanity check.
---
 libstdc++-v3/include/std/charconv | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/include/std/charconv 
b/libstdc++-v3/include/std/charconv
index e516e3b2da8..00c4f206922 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -126,7 +126,7 @@ namespace __detail
 
   const unsigned __len = __to_chars_len(__val, __base);
 
-  if (__builtin_expect((__last - __first) < __len, 0))
+  if (__builtin_expect(size_t(__last - __first) < __len, 0))
{
  __res.ptr = __last;
  __res.ec = errc::value_too_large;
@@ -166,7 +166,7 @@ namespace __detail
 
   const unsigned __len = (__to_chars_len_2(__val) + 3) / 4;
 
-  if (__builtin_expect((__last - __first) < __len, 0))
+  if (__builtin_expect(size_t(__last - __first) < __len, 0))
{
  __res.ptr = __last;
  __res.ec = errc::value_too_large;
@@ -212,7 +212,7 @@ namespace __detail
 
   const unsigned __len = __to_chars_len(__val, 10);
 
-  if (__builtin_expect((__last - __first) < __len, 0))
+  if (__builtin_expect(size_t(__last - __first) < __len, 0))
{
  __res.ptr = __last;
  __res.ec = errc::value_too_large;
@@ -246,7 +246,7 @@ namespace __detail
   else
__len = (__to_chars_len_2(__val) + 2) / 3;
 
-  if (__builtin_expect((__last - __first) < __len, 0))
+  if (__builtin_expect(size_t(__last - __first) < __len, 0))
{
  __res.ptr = __last;
  __res.ec = errc::value_too_large;
@@ -288,7 +288,7 @@ namespace __detail
 
   const unsigned __len = __to_chars_len_2(__val);
 
-  if (__builtin_expect((__last - __first) < __len, 0))
+  if (__builtin_expect(size_t(__last - __first) < __len, 0))
{
  __res.ptr = __last;
  __res.ec = errc::value_too_large;
@@ -323,7 +323,7 @@ namespace __detail
   using _Up = __detail::__unsigned_least_t<_Tp>;
   _Up __unsigned_val = __value;
 
-  if (__first == __last) [[__unlikely__]]
+  if (__first >= __last) [[__unlikely__]]
return { __last, errc::value_too_large };
 
   if (__value == 0)
-- 
2.45.2



[committed] libstdc++: Add comment noting LWG 3617 support

2024-07-27 Thread Jonathan Wakely
Tested x86_64-linux. Pushed to trunk.

-- >8 --

The resolution was implemented in r14-8752-g6f75149488b74a but I didn't
add the usual _GLIBCXX_RESOLVE_LIB_DEFECTS comment.

libstdc++-v3/ChangeLog:

* include/bits/std_function.h: Add comment about LWG 3617 being
supported.
---
 libstdc++-v3/include/bits/std_function.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libstdc++-v3/include/bits/std_function.h 
b/libstdc++-v3/include/bits/std_function.h
index 79b59466fe9..bb8d8b9306c 100644
--- a/libstdc++-v3/include/bits/std_function.h
+++ b/libstdc++-v3/include/bits/std_function.h
@@ -698,6 +698,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 { using type = _Res(_Args...); };
 
 #if __cpp_explicit_this_parameter >= 202110L
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 3617. function/packaged_task deduction guides and deducing this
   template
 struct __function_guide_helper<_Res (*) (_Tp, _Args...) noexcept(_Nx)>
 { using type = _Res(_Args...); };
-- 
2.45.2



Re: [PATCH] fortran: Support optional dummy as BACK argument of MINLOC/MAXLOC.

2024-07-27 Thread rep . dot . nop
On 22 July 2024 20:53:18 CEST, Mikael Morin  wrote:
>From: Mikael Morin 
>
>Hello,
>
>this fixes a null pointer dereference with absent optional dummy passed
>as BACK argument of MINLOC/MAXLOC.
>
>Tested for regression on x86_64-linux.
>OK for master?
>
>-- >8 --
>
>Protect the evaluation of BACK with a check that the reference is non-null
>in case the expression is an optional dummy, in the inline code generated
>for MINLOC and MAXLOC.
>
>This change contains a revert of the non-testsuite part of commit
>r15-1994-ga55d24b3cf7f4d07492bb8e6fcee557175b47ea3, which factored the
>evaluation of BACK out of the loop using the scalarizer.  It was a bad idea,
>because delegating the argument evaluation to the scalarizer makes it
>cumbersome to add a null pointer check next to the evaluation.
>
>Instead, evaluate BACK at the beginning, before scalarization, add a check
>that the argument is present if necessary, and evaluate the resulting
>expression to a variable, before using the variable in the inline code.
>
>gcc/fortran/ChangeLog:
>
>   * trans-intrinsic.cc (maybe_absent_optional_variable): New function.
>   (gfc_conv_intrinsic_minmaxloc): Remove BACK from scalarization and
>   evaluate it before.  Add a check that BACK is not null if the
>   expression is an optional dummy.  Save the resulting expression to a
>   variable.  Use the variable in the generated inline code.
>
>gcc/testsuite/ChangeLog:
>
>   * gfortran.dg/maxloc_6.f90: New test.
>   * gfortran.dg/minloc_7.f90: New test.
>---
> gcc/fortran/trans-intrinsic.cc |  81 +-
> gcc/testsuite/gfortran.dg/maxloc_6.f90 | 366 +
> gcc/testsuite/gfortran.dg/minloc_7.f90 | 366 +
> 3 files changed, 799 insertions(+), 14 deletions(-)
> create mode 100644 gcc/testsuite/gfortran.dg/maxloc_6.f90
> create mode 100644 gcc/testsuite/gfortran.dg/minloc_7.f90
>
>diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
>index 180d0d7a88c..9f3c3ce47bc 100644
>--- a/gcc/fortran/trans-intrinsic.cc
>+++ b/gcc/fortran/trans-intrinsic.cc
>@@ -5209,6 +5209,50 @@ gfc_conv_intrinsic_dot_product (gfc_se * se, gfc_expr * 
>expr)
> }
> 
> 
>+/* Tells whether the expression E is a reference to an optional variable whose
>+   presence is not known at compile time.  Those are variable references 
>without
>+   subreference; if there is a subreference, we can assume the variable is
>+   present.  We have to special case full arrays, which we represent with a 
>fake
>+   "full" reference, and class descriptors for which a reference to data is 
>not
>+   really a subreference.  */
>+
>+bool
>+maybe_absent_optional_variable (gfc_expr *e)
>+{
>+  if (!(e && e->expr_type == EXPR_VARIABLE))
>+return false;

[]

>+}
>+
>+
> /* Remove unneeded kind= argument from actual argument list when the
>result conversion is dealt with in a different place.  */
> 
>@@ -5321,11 +5365,11 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * 
>expr, enum tree_code op)
>   tree nonempty;
>   tree lab1, lab2;
>   tree b_if, b_else;
>+  tree back;
>   gfc_loopinfo loop;
>   gfc_actual_arglist *actual;
>   gfc_ss *arrayss;
>   gfc_ss *maskss;
>-  gfc_ss *backss;
>   gfc_se arrayse;
>   gfc_se maskse;
>   gfc_expr *arrayexpr;
>@@ -5391,10 +5435,27 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * 
>expr, enum tree_code op)
> && maskexpr->symtree->n.sym->attr.dummy
> && maskexpr->symtree->n.sym->attr.optional;
>   backexpr = actual->next->next->expr;
>-  if (backexpr)
>-backss = gfc_get_scalar_ss (gfc_ss_terminator, backexpr);
>+
>+  gfc_init_se (&backse, NULL);
>+  if (backexpr == nullptr)
>+back = logical_false_node;
>+  else if (maybe_absent_optional_variable (backexpr))
>+{

/* if this fires, some wonky race is going on.. */

>+  gcc_assert (backexpr->expr_type == EXPR_VARIABLE);

drop it, downgrade to checking, or is it worth?

>+
>+  gfc_conv_expr (&backse, backexpr);
>+  tree present = gfc_conv_expr_present (backexpr->symtree->n.sym, false);
>+  back = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
>+logical_type_node, present, backse.expr);
>+}
>   else
>-backss = nullptr;
>+{
>+  gfc_conv_expr (&backse, backexpr);
>+  back = backse.expr;
>+}
>+  gfc_add_block_to_block (&se->pre, &backse.pre);
>+  back = gfc_evaluate_now_loc (input_location, back, &se->pre);
>+  gfc_add_block_to_block (&se->pre, &backse.post);
> 
>   nonempty = NULL

[]
thanks


[nvptx PATCH] Implement isfinite and isnormal optabs in nvptx.md.

2024-07-27 Thread Roger Sayle

Firstly, thanks to Haochen Gui for recently adding optab support for
isfinite and isnormal to the middle-end.  This patch adds define_expand
for both these functions to the nvptx backend, which conveniently has
special instructions to simplify their implementation.  As this patch
adds UNSPEC_ISFINITE and UNSPEC_ISNORMAL, I've also taken the opportunity
to include/repost my tweak to clean-up/eliminate UNSPEC_COPYSIGN.

Previously, for isfinite, GCC on nvptx-none with -O2 would generate:

mov.f64 %r26, %ar0;
abs.f64 %r28, %r26;
setp.gtu.f64%r31, %r28, 0d7fef;
selp.u32%value, 0, 1, %r31;

and with this patch, we now generate:

mov.f64 %r23, %ar0;
testp.finite.f64%r24, %r23;
selp.u32%value, 1, 0, %r24;

Previously, for isnormal, GCC -O2 would generate:

mov.f64 %r28, %ar0;
abs.f64 %r22, %r28;
setp.gtu.f64%r32, %r22, 0d7fef;
setp.ltu.f64%r35, %r22, 0d0010;
or.pred %r43, %r35, %r32;
selp.u32%value, 0, 1, %r43;

and with this patch becomes:

mov.f64 %r23, %ar0;
setp.neu.f64%r24, %r23, 0d;
testp.normal.f64%r25, %r23;
and.pred%r26, %r24, %r25;
selp.u32%value, 1, 0, %r26;

Notice that although nvptx provides a testp.normal.f{32,64} instruction,
the semantics don't quite match those required of libm [+0.0 and -0.0
are considered normal by this instruction, but need to return false
for __builtin_isnormal, hence the additional logic, which is still
better than the original].

This patch has been tested on nvptx-none hosted by x86_64-pc-linux-gnu
using make and make -k check, with only one new failure in the testsuite.
The test case g++.dg/opt/pr107569.C exposes a latent bug in the middle-end
(actually a missed optimization) as evrp fails to bound the results of
isfinite.  This issue is independent of the back-end, as the tree-ssa
evrp pass is run long before __builtin_finite is expanded by the backend,
and the existence of an (any) isfinite optab is sufficient to expose it.
Fortunately, Haochem Gui has already posted/proposed a fix at
https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657881.html
[which I'm sad to see is taking a while to review/get approved].

Ok for mainline?


2024-07-27  Roger Sayle  

gcc/ChangeLog
* config/nvptx/nptx.md (UNSPEC_COPYSIGN): No longer required.
(UNSPEC_ISFINITE): New UNSPEC.
(UNSPEC_ISNORMAL): Likewise.
(*cmp): Rename to...
(cmp): Remove '*' prefix to generate gen_cmp{s,d}f.
(copysign3): Replace UNSPEC_COPYSIGN with copysign RTX.
(*setcc_isfinite): New define_insn using UNSPEC_ISFINITE.
(isfinite2): Expand isfinite.
(*setcc_isnormal): New define_insn using UNSPEC_ISNORMAL.
(isnormal2): Expand isnormal.

gcc/testsuite/ChangeLog
* gcc.target/nvptx/isfinite.c: New test case.
* gcc.target/nvptx/isnormal.c: Likewise.


Thanks in advance (p.s. don't forget the nvptx_rtx_costs patch),
Roger
--

diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 7878a3b..ae711bb 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -21,13 +21,14 @@
 (define_c_enum "unspec" [
UNSPEC_ARG_REG
 
-   UNSPEC_COPYSIGN
UNSPEC_LOG2
UNSPEC_EXP2
UNSPEC_SIN
UNSPEC_COS
UNSPEC_TANH
UNSPEC_ISINF
+   UNSPEC_ISFINITE
+   UNSPEC_ISNORMAL
 
UNSPEC_FPINT_FLOOR
UNSPEC_FPINT_BTRUNC
@@ -888,7 +889,7 @@
   ""
   "%.\\tsetp%c1\\t%0, %2, %3;")
 
-(define_insn "*cmp"
+(define_insn "cmp"
   [(set (match_operand:BI 0 "nvptx_register_operand" "=R")
(match_operator:BI 1 "nvptx_float_comparison_operator"
   [(match_operand:SDFM 2 "nvptx_register_operand" "R")
@@ -1253,9 +1254,8 @@
 
 (define_insn "copysign3"
   [(set (match_operand:SDFM 0 "nvptx_register_operand" "=R")
-   (unspec:SDFM [(match_operand:SDFM 1 "nvptx_nonmemory_operand" "RF")
- (match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF")]
- UNSPEC_COPYSIGN))]
+   (copysign:SDFM (match_operand:SDFM 1 "nvptx_nonmemory_operand" "RF")
+  (match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF")))]
   ""
   "%.\\tcopysign%t0\\t%0, %2, %1;")
 
@@ -1330,6 +1330,8 @@
   "flag_unsafe_math_optimizations"
   "%.\\tex2.approx%t0\\t%0, %1;")
 
+;; FP classify predicates
+
 (define_insn "setcc_isinf"
   [(set (match_operand:BI 0 "nvptx_register_operand" "=R")
(unspec:BI [(match_operand:SDFM 1 "nvptx_register_operand" "R")]
@@ -1349,6 +1351,50 @@
   DONE;
 })
 
+(define_insn "setcc_isfinite"
+  [(set (match_operand:BI 0 "nvptx_register_operand" "=R")
+   (unspec:BI [(match_operand:SDFM 1 "nvptx_register_operand" "R")]
+  

ping: [PATCH] libcpp: Support extended characters for #pragma {push,pop}_macro [PR109704]

2024-07-27 Thread Lewis Hyatt
Hello-

https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642926.html

Ping please? Jakub + Jason, hope you don't mind that I CCed you, I saw
you had your attention on extended character identifiers a bit now :).
Thanks!

-Lewis

On Fri, Jul 5, 2024 at 4:23 PM Lewis Hyatt  wrote:
>
> Hello-
>
> https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642926.html
>
> May I please ping this one again? It's the largest remaining gap in
> UTF-8 support for libcpp that I know of. Thanks!
>
> -Lewis
>
> On Tue, May 28, 2024 at 7:46 PM Lewis Hyatt  wrote:
> >
> > Hello-
> >
> > May I please ping this one (now for GCC 15)? Thanks!
> > https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642926.html
> >
> > -Lewis
> >
> > On Sat, Feb 10, 2024 at 9:02 AM Lewis Hyatt  wrote:
> > >
> > > Hello-
> > >
> > > https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642926.html
> > >
> > > May I please ping this one? Thanks!
> > >
> > > On Sat, Jan 13, 2024 at 5:12 PM Lewis Hyatt  wrote:
> > > >
> > > > Hello-
> > > >
> > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109704
> > > >
> > > > The below patch fixes the issue noted in the PR that extended characters
> > > > cannot appear in the identifier passed to a #pragma push_macro or 
> > > > #pragma
> > > > pop_macro. Bootstrap + regtest all languages on x86-64 Linux. Is it OK 
> > > > for
> > > > GCC 13 please?


Re: [PATCH] fortran: Support optional dummy as BACK argument of MINLOC/MAXLOC.

2024-07-27 Thread Mikael Morin

Le 27/07/2024 à 19:23, rep.dot@gmail.com a écrit :

On 22 July 2024 20:53:18 CEST, Mikael Morin  wrote:

From: Mikael Morin 

Hello,

this fixes a null pointer dereference with absent optional dummy passed
as BACK argument of MINLOC/MAXLOC.

Tested for regression on x86_64-linux.
OK for master?

-- >8 --

Protect the evaluation of BACK with a check that the reference is non-null
in case the expression is an optional dummy, in the inline code generated
for MINLOC and MAXLOC.

This change contains a revert of the non-testsuite part of commit
r15-1994-ga55d24b3cf7f4d07492bb8e6fcee557175b47ea3, which factored the
evaluation of BACK out of the loop using the scalarizer.  It was a bad idea,
because delegating the argument evaluation to the scalarizer makes it
cumbersome to add a null pointer check next to the evaluation.

Instead, evaluate BACK at the beginning, before scalarization, add a check
that the argument is present if necessary, and evaluate the resulting
expression to a variable, before using the variable in the inline code.

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (maybe_absent_optional_variable): New function.
(gfc_conv_intrinsic_minmaxloc): Remove BACK from scalarization and
evaluate it before.  Add a check that BACK is not null if the
expression is an optional dummy.  Save the resulting expression to a
variable.  Use the variable in the generated inline code.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_6.f90: New test.
* gfortran.dg/minloc_7.f90: New test.
---
gcc/fortran/trans-intrinsic.cc |  81 +-
gcc/testsuite/gfortran.dg/maxloc_6.f90 | 366 +
gcc/testsuite/gfortran.dg/minloc_7.f90 | 366 +
3 files changed, 799 insertions(+), 14 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/maxloc_6.f90
create mode 100644 gcc/testsuite/gfortran.dg/minloc_7.f90

diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 180d0d7a88c..9f3c3ce47bc 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -5209,6 +5209,50 @@ gfc_conv_intrinsic_dot_product (gfc_se * se, gfc_expr * 
expr)
}


+/* Tells whether the expression E is a reference to an optional variable whose
+   presence is not known at compile time.  Those are variable references 
without
+   subreference; if there is a subreference, we can assume the variable is
+   present.  We have to special case full arrays, which we represent with a 
fake
+   "full" reference, and class descriptors for which a reference to data is not
+   really a subreference.  */
+
+bool
+maybe_absent_optional_variable (gfc_expr *e)
+{
+  if (!(e && e->expr_type == EXPR_VARIABLE))
+return false;


[]


+}
+
+
/* Remove unneeded kind= argument from actual argument list when the
result conversion is dealt with in a different place.  */

@@ -5321,11 +5365,11 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * 
expr, enum tree_code op)
   tree nonempty;
   tree lab1, lab2;
   tree b_if, b_else;
+  tree back;
   gfc_loopinfo loop;
   gfc_actual_arglist *actual;
   gfc_ss *arrayss;
   gfc_ss *maskss;
-  gfc_ss *backss;
   gfc_se arrayse;
   gfc_se maskse;
   gfc_expr *arrayexpr;
@@ -5391,10 +5435,27 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * 
expr, enum tree_code op)
 && maskexpr->symtree->n.sym->attr.dummy
 && maskexpr->symtree->n.sym->attr.optional;
   backexpr = actual->next->next->expr;
-  if (backexpr)
-backss = gfc_get_scalar_ss (gfc_ss_terminator, backexpr);
+
+  gfc_init_se (&backse, NULL);
+  if (backexpr == nullptr)
+back = logical_false_node;
+  else if (maybe_absent_optional_variable (backexpr))
+{


/* if this fires, some wonky race is going on.. */


+  gcc_assert (backexpr->expr_type == EXPR_VARIABLE);


drop it, downgrade to checking, or is it worth?

Whether it is worth it, I don't know; it's protecting the access to 
backexpr->symtree a few lines down, idependently of the implementation 
of maybe_absent_optional_variable.


I expect the compiler to optimize it away, so I can surely make it a 
checking-only assert.



+
+  gfc_conv_expr (&backse, backexpr);
+  tree present = gfc_conv_expr_present (backexpr->symtree->n.sym, false);
+  back = fold_build2_loc (input_location, TRUTH_ANDIF_EXPR,
+ logical_type_node, present, backse.expr);
+}
   else
-backss = nullptr;
+{
+  gfc_conv_expr (&backse, backexpr);
+  back = backse.expr;
+}
+  gfc_add_block_to_block (&se->pre, &backse.pre);
+  back = gfc_evaluate_now_loc (input_location, back, &se->pre);
+  gfc_add_block_to_block (&se->pre, &backse.post);

   nonempty = NULL


[]
thanks




Re: [PATCH] LoongArch: Use iorn and andn standard pattern names for scalar modes.

2024-07-27 Thread Andrew Pinski
On Sat, Jul 27, 2024 at 1:38 AM Lulu Cheng  wrote:
>
> gcc/ChangeLog:
>
> * config/loongarch/loongarch.md (n): Rename to ...
> (n3): This.


Thanks for doing this for loongarch. Once I finish up my patch set;
loongarch should get benefit. Also it might be useful after my patch
set goes in that a loongarch specific testcases are added too. I
estimate by the end of this coming week when it will be done/approved
but that is just an estimate.

Thanks,
Andrew

> ---
>  gcc/config/loongarch/loongarch.md | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/config/loongarch/loongarch.md 
> b/gcc/config/loongarch/loongarch.md
> index 459ad30b9bb..4e4ddd515c9 100644
> --- a/gcc/config/loongarch/loongarch.md
> +++ b/gcc/config/loongarch/loongarch.md
> @@ -1668,7 +1668,7 @@ (define_insn "*norsi3_internal"
>[(set_attr "type" "logical")
> (set_attr "mode" "SI")])
>
> -(define_insn "n"
> +(define_insn "n3"
>[(set (match_operand:X 0 "register_operand" "=r")
> (neg_bitwise:X
> (not:X (match_operand:X 1 "register_operand" "r"))
> --
> 2.39.3
>


Re: [PATCH] LoongArch: Use iorn and andn standard pattern names.

2024-07-27 Thread Andrew Pinski
On Sat, Jul 27, 2024 at 1:55 AM Lulu Cheng  wrote:
>
> gcc/ChangeLog:
>
> * config/loongarch/lasx.md (xvandn3): Rename to ...
> (andn3): This.
> (xvorn3): Rename to ...
> (iorn3): This.
> * config/loongarch/loongarch-builtins.cc (CODE_FOR_lsx_vandn_v):
> Defined as the modified name.
> (CODE_FOR_lsx_vorn_v): Likewise.
> (CODE_FOR_lasx_xvandn_v): Likewise.
> (CODE_FOR_lasx_xvorn_v): Likewise.
> * config/loongarch/loongarch.md (n): Rename to ...
> (n3): This.
> * config/loongarch/lsx.md (vandn3): Rename to ...
> (andn3): This. .
> (vorn3): Rename to ...
> (iorn3): This.


You might want to add a testcase like I did for aarch64:
https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658219.html .

Thanks,
Andrew Pinski

> ---
>  gcc/config/loongarch/lasx.md   | 4 ++--
>  gcc/config/loongarch/loongarch-builtins.cc | 8 
>  gcc/config/loongarch/loongarch.md  | 2 +-
>  gcc/config/loongarch/lsx.md| 4 ++--
>  4 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/config/loongarch/lasx.md b/gcc/config/loongarch/lasx.md
> index 7bd61f8ed5b..c5fe04de86c 100644
> --- a/gcc/config/loongarch/lasx.md
> +++ b/gcc/config/loongarch/lasx.md
> @@ -2716,7 +2716,7 @@ (define_insn "lasx_vext2xv_d_b"
> (set_attr "mode" "V4DI")])
>
>  ;; Extend loongson-sx to loongson-asx.
> -(define_insn "xvandn3"
> +(define_insn "andn3"
>[(set (match_operand:LASX 0 "register_operand" "=f")
> (and:LASX (not:LASX (match_operand:LASX 1 "register_operand" "f"))
> (match_operand:LASX 2 "register_operand" "f")))]
> @@ -4637,7 +4637,7 @@ (define_insn "lasx_xvssrlrn__"
>[(set_attr "type" "simd_int_arith")
> (set_attr "mode" "")])
>
> -(define_insn "xvorn3"
> +(define_insn "iorn3"
>[(set (match_operand:ILASX 0 "register_operand" "=f")
> (ior:ILASX (not:ILASX (match_operand:ILASX 2 "register_operand" "f"))
>(match_operand:ILASX 1 "register_operand" "f")))]
> diff --git a/gcc/config/loongarch/loongarch-builtins.cc 
> b/gcc/config/loongarch/loongarch-builtins.cc
> index fbe46833c9b..f0de80d767b 100644
> --- a/gcc/config/loongarch/loongarch-builtins.cc
> +++ b/gcc/config/loongarch/loongarch-builtins.cc
> @@ -458,8 +458,8 @@ AVAIL_ALL (lasx_frecipe, ISA_HAS_LASX && ISA_HAS_FRECIPE)
>  #define CODE_FOR_lsx_vabsd_du CODE_FOR_lsx_vabsd_u_du
>  #define CODE_FOR_lsx_vftint_wu_s CODE_FOR_lsx_vftint_u_wu_s
>  #define CODE_FOR_lsx_vftint_lu_d CODE_FOR_lsx_vftint_u_lu_d
> -#define CODE_FOR_lsx_vandn_v CODE_FOR_vandnv16qi3
> -#define CODE_FOR_lsx_vorn_v CODE_FOR_vornv16qi3
> +#define CODE_FOR_lsx_vandn_v CODE_FOR_andnv16qi3
> +#define CODE_FOR_lsx_vorn_v CODE_FOR_iornv16qi3
>  #define CODE_FOR_lsx_vneg_b CODE_FOR_vnegv16qi2
>  #define CODE_FOR_lsx_vneg_h CODE_FOR_vnegv8hi2
>  #define CODE_FOR_lsx_vneg_w CODE_FOR_vnegv4si2
> @@ -692,8 +692,8 @@ AVAIL_ALL (lasx_frecipe, ISA_HAS_LASX && ISA_HAS_FRECIPE)
>  #define CODE_FOR_lasx_xvrepli_w CODE_FOR_lasx_xvrepliv8si
>  #define CODE_FOR_lasx_xvrepli_d CODE_FOR_lasx_xvrepliv4di
>
> -#define CODE_FOR_lasx_xvandn_v CODE_FOR_xvandnv32qi3
> -#define CODE_FOR_lasx_xvorn_v CODE_FOR_xvornv32qi3
> +#define CODE_FOR_lasx_xvandn_v CODE_FOR_andnv32qi3
> +#define CODE_FOR_lasx_xvorn_v CODE_FOR_iornv32qi3
>  #define CODE_FOR_lasx_xvneg_b CODE_FOR_negv32qi2
>  #define CODE_FOR_lasx_xvneg_h CODE_FOR_negv16hi2
>  #define CODE_FOR_lasx_xvneg_w CODE_FOR_negv8si2
> diff --git a/gcc/config/loongarch/loongarch.md 
> b/gcc/config/loongarch/loongarch.md
> index 459ad30b9bb..4e4ddd515c9 100644
> --- a/gcc/config/loongarch/loongarch.md
> +++ b/gcc/config/loongarch/loongarch.md
> @@ -1668,7 +1668,7 @@ (define_insn "*norsi3_internal"
>[(set_attr "type" "logical")
> (set_attr "mode" "SI")])
>
> -(define_insn "n"
> +(define_insn "n3"
>[(set (match_operand:X 0 "register_operand" "=r")
> (neg_bitwise:X
> (not:X (match_operand:X 1 "register_operand" "r"))
> diff --git a/gcc/config/loongarch/lsx.md b/gcc/config/loongarch/lsx.md
> index 454cda47876..dcb667a6ce5 100644
> --- a/gcc/config/loongarch/lsx.md
> +++ b/gcc/config/loongarch/lsx.md
> @@ -2344,7 +2344,7 @@ (define_insn_and_split "vec_concatv4sf"
>  }
>[(set_attr "mode" "V4SF")])
>
> -(define_insn "vandn3"
> +(define_insn "andn3"
>[(set (match_operand:LSX 0 "register_operand" "=f")
> (and:LSX (not:LSX (match_operand:LSX 1 "register_operand" "f"))
>  (match_operand:LSX 2 "register_operand" "f")))]
> @@ -3028,7 +3028,7 @@ (define_insn "lsx_vssrlrn__"
>[(set_attr "type" "simd_int_arith")
> (set_attr "mode" "")])
>
> -(define_insn "vorn3"
> +(define_insn "iorn3"
>[(set (match_operand:ILSX 0 "register_operand" "=f")
> (ior:ILSX (not:ILSX (match_operand:ILSX 2 "register_operand" "f"))
>   (match_operand:ILSX 1 "register_operand" "f")))]
> --
> 2.39.3
>


Re: [PATCH] fortran: Support optional dummy as BACK argument of MINLOC/MAXLOC.

2024-07-27 Thread rep . dot . nop
On 27 July 2024 21:11:19 CEST, Mikael Morin  wrote:
>Le 27/07/2024 à 19:23, rep.dot@gmail.com a écrit :
>> On 22 July 2024 20:53:18 CEST, Mikael Morin  wrote:
>>> From: Mikael Morin 
>>> 
>>> Hello,
>>> 
>>> this fixes a null pointer dereference with absent optional dummy passed
>>> as BACK argument of MINLOC/MAXLOC.
>>> 
>>> Tested for regression on x86_64-linux.
>>> OK for master?
>>> 
>>> -- >8 --
>>> 
>>> Protect the evaluation of BACK with a check that the reference is non-null
>>> in case the expression is an optional dummy, in the inline code generated
>>> for MINLOC and MAXLOC.
>>> 
>>> This change contains a revert of the non-testsuite part of commit
>>> r15-1994-ga55d24b3cf7f4d07492bb8e6fcee557175b47ea3, which factored the
>>> evaluation of BACK out of the loop using the scalarizer.  It was a bad idea,
>>> because delegating the argument evaluation to the scalarizer makes it
>>> cumbersome to add a null pointer check next to the evaluation.
>>> 
>>> Instead, evaluate BACK at the beginning, before scalarization, add a check
>>> that the argument is present if necessary, and evaluate the resulting
>>> expression to a variable, before using the variable in the inline code.
>>> 
>>> gcc/fortran/ChangeLog:
>>> 
>>> * trans-intrinsic.cc (maybe_absent_optional_variable): New function.
>>> (gfc_conv_intrinsic_minmaxloc): Remove BACK from scalarization and
>>> evaluate it before.  Add a check that BACK is not null if the
>>> expression is an optional dummy.  Save the resulting expression to a
>>> variable.  Use the variable in the generated inline code.
>>> 
>>> gcc/testsuite/ChangeLog:
>>> 
>>> * gfortran.dg/maxloc_6.f90: New test.
>>> * gfortran.dg/minloc_7.f90: New test.
>>> ---
>>> gcc/fortran/trans-intrinsic.cc |  81 +-
>>> gcc/testsuite/gfortran.dg/maxloc_6.f90 | 366 +
>>> gcc/testsuite/gfortran.dg/minloc_7.f90 | 366 +
>>> 3 files changed, 799 insertions(+), 14 deletions(-)
>>> create mode 100644 gcc/testsuite/gfortran.dg/maxloc_6.f90
>>> create mode 100644 gcc/testsuite/gfortran.dg/minloc_7.f90
>>> 
>>> diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
>>> index 180d0d7a88c..9f3c3ce47bc 100644
>>> --- a/gcc/fortran/trans-intrinsic.cc
>>> +++ b/gcc/fortran/trans-intrinsic.cc
>>> @@ -5209,6 +5209,50 @@ gfc_conv_intrinsic_dot_product (gfc_se * se, 
>>> gfc_expr * expr)
>>> }
>>> 
>>> 
>>> +/* Tells whether the expression E is a reference to an optional variable 
>>> whose
>>> +   presence is not known at compile time.  Those are variable references 
>>> without
>>> +   subreference; if there is a subreference, we can assume the variable is
>>> +   present.  We have to special case full arrays, which we represent with 
>>> a fake
>>> +   "full" reference, and class descriptors for which a reference to data 
>>> is not
>>> +   really a subreference.  */
>>> +
>>> +bool
>>> +maybe_absent_optional_variable (gfc_expr *e)
>>> +{
>>> +  if (!(e && e->expr_type == EXPR_VARIABLE))
>>> +return false;
>> 
>> []
>> 
>>> +}
>>> +
>>> +
>>> /* Remove unneeded kind= argument from actual argument list when the
>>> result conversion is dealt with in a different place.  */
>>> 
>>> @@ -5321,11 +5365,11 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr 
>>> * expr, enum tree_code op)
>>>tree nonempty;
>>>tree lab1, lab2;
>>>tree b_if, b_else;
>>> +  tree back;
>>>gfc_loopinfo loop;
>>>gfc_actual_arglist *actual;
>>>gfc_ss *arrayss;
>>>gfc_ss *maskss;
>>> -  gfc_ss *backss;
>>>gfc_se arrayse;
>>>gfc_se maskse;
>>>gfc_expr *arrayexpr;
>>> @@ -5391,10 +5435,27 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr 
>>> * expr, enum tree_code op)
>>>  && maskexpr->symtree->n.sym->attr.dummy
>>>  && maskexpr->symtree->n.sym->attr.optional;
>>>backexpr = actual->next->next->expr;
>>> -  if (backexpr)
>>> -backss = gfc_get_scalar_ss (gfc_ss_terminator, backexpr);
>>> +
>>> +  gfc_init_se (&backse, NULL);
>>> +  if (backexpr == nullptr)
>>> +back = logical_false_node;
>>> +  else if (maybe_absent_optional_variable (backexpr))
>>> +{
>> 
>> /* if this fires, some wonky race is going on.. */
>> 
>>> +  gcc_assert (backexpr->expr_type == EXPR_VARIABLE);
>> 
>> drop it, downgrade to checking, or is it worth?
>> 
>Whether it is worth it, I don't know; it's protecting the access to 
>backexpr->symtree a few lines down, idependently of the implementation of 
>maybe_absent_optional_variable.

nod

>
>I expect the compiler to optimize it away,

ye[l]*p 

> so I can surely make it a checking-only assert.

let's keep the assert unless someone opts for any downgrade within 72h ?

maybe add the comment if an assert persists, though. LGTM otherwise AFAIC


[pushed] c++: improve C++ testsuite default versions

2024-07-27 Thread Jason Merrill
Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

I wanted to add more cases to the setting of std_list in g++-dg.exp, but
didn't want to do a full scan through the file for each case.  So this patch
improves that in two ways: first, by extracting all interesting lines on a
single pass; second, by generating the list more flexibly: now we test every
version mentioned explicitly in the testcase, plus a few more if fewer than
three are mentioned.

This also lowers changes from testing four to three versions for most
testcases: the current default and the earliest and latest versions.  This
will reduce testing of C++14 and C++20 modes, and increase testing of C++26
mode.  C++ front-end developers are encouraged to set the
GXX_TESTSUITE_STDS environment variable to test more modes.

gcc/testsuite/ChangeLog:

* lib/gcc-dg.exp (get_matching_lines): New.
* lib/g++-dg.exp: Improve std_list selection.
---
 gcc/testsuite/lib/g++-dg.exp | 45 +---
 gcc/testsuite/lib/gcc-dg.exp | 13 +++
 2 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp
index 52fba75c4a3..991be4d3867 100644
--- a/gcc/testsuite/lib/g++-dg.exp
+++ b/gcc/testsuite/lib/g++-dg.exp
@@ -53,21 +53,38 @@ proc g++-dg-runtest { testcases flags default-extra-flags } 
{
if { [llength $gpp_std_list] > 0 } {
set std_list $gpp_std_list
} else {
-   # If the test requires a newer C++ version than which
-   # is tested by default, use that C++ version for that
-   # single test.  Or if a test checks behavior specifically for
-   # one C++ version, include that version in the default list.
-   # These should be adjusted whenever the default std_list is
-   # updated or newer C++ effective target is added.
-   if [search_for $test "\{ dg-do * \{ target c++23"] {
-   set std_list { 23 26 }
-   } elseif [search_for $test "\{ dg-do * \{ target c++26"] {
-   set std_list { 26 }
-   } elseif [search_for $test "c++11_only"] {
-   set std_list { 98 11 14 20 }
-   } else {
-   set std_list { 98 14 17 20 }
+   # If the test mentions specific C++ versions, test those.
+   set lines [get_matching_lines $test {\{ dg* c++[0-9][0-9]}]
+   set std_list {}
+   set low 0
+   foreach line $lines {
+   regexp {c\+\+([0-9][0-9])} $line -> ver
+   lappend std_list $ver
+
+   if { $ver == 98 } {
+   # Leave low alone.
+   } elseif { [regexp {dg-do|dg-require-effective-target} 
$line] } {
+   set low $ver
+   }
}
+   #verbose "low: $low" 1
+
+   set std_list [lsort -unique $std_list]
+
+   # If fewer than 3 specific versions are mentioned, add more.
+   # The order of this list is significant: first $cxx_default,
+   # then the oldest and newest, then others in rough order of
+   # importance based on test coverage and usage.
+   foreach ver { 17 98 26 11 20 14 23 } {
+   set cmpver $ver
+   if { $ver == 98 } { set cmpver 03 }
+   if { [llength $std_list] < 3
+&& $ver ni $std_list
+&& $cmpver > $low } {
+   lappend std_list $ver
+   }
+   }
+   verbose "std_list: $std_list" 1
}
set option_list { }
foreach x $std_list {
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 228c21d1207..992062103c1 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -574,6 +574,19 @@ proc search_for { file pattern } {
 return 0
 }
 
+# get_matching_lines -- return a list of matching lines in file
+proc get_matching_lines { file pattern } {
+set lines {}
+set fd [open $file r]
+while { [gets $fd cur_line]>=0 } {
+   if [string match "*$pattern*" $cur_line] then {
+   lappend lines $cur_line
+   }
+}
+close $fd
+return $lines
+}
+
 # Modified dg-runtest that can cycle through a list of optimization options
 # as c-torture does.
 proc gcc-dg-runtest { testcases flags default-extra-flags } {

base-commit: 928116e94a5a8a995dffd926af58abfa7286e78e
-- 
2.45.2



[pushed] c++: ICE with concept, local class, and lambda [PR115561]

2024-07-27 Thread Jason Merrill
Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

Here when we want to synthesize methods for foo()::B maybe_push_to_top_level
calls push_function_context, which sets cfun to a dummy value; later
finish_call_expr tries to set something in
cp_function_chain (i.e. cfun->language), which isn't set.  Many places in
the compiler check cfun && cp_function_chain to avoid this problem; here we
also want to check !cp_unevaluated_operand, like set_flags_from_callee does.

PR c++/115561

gcc/cp/ChangeLog:

* semantics.cc (finish_call_expr): Check cp_unevaluated_operand.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-lambda21.C: New test.
---
 gcc/cp/semantics.cc   |  2 +-
 .../g++.dg/cpp2a/concepts-lambda21.C  | 69 +++
 2 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-lambda21.C

diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 0f122b839c5..a9abf32e01f 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -2968,7 +2968,7 @@ finish_call_expr (tree fn, vec **args, bool 
disallow_virtual,
 -Wredundant-move warning.  */
  suppress_warning (result, OPT_Wpessimizing_move);
 
- if (cfun)
+ if (cfun && cp_function_chain && !cp_unevaluated_operand)
{
  bool abnormal = true;
  for (lkp_iterator iter (maybe_get_fns (fn)); iter; ++iter)
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-lambda21.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-lambda21.C
new file mode 100644
index 000..8d701cd4bbc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-lambda21.C
@@ -0,0 +1,69 @@
+// PR c++/115561
+// { dg-do compile { target c++20 } }
+
+template
+auto declval() noexcept -> _Tp&&;
+
+template
+struct enable_if
+{ };
+
+template
+struct enable_if
+{ using type = _Tp; };
+
+template
+using enable_if_t = typename enable_if<_Cond, _Tp>::type;
+
+template
+struct is_void
+{ static constexpr bool value = false;  };
+
+template
+using invoke_result_t =
+decltype(declval()(declval()...));
+
+template
+using iter_reference_t = decltype(*declval());
+
+struct iter_move_fn
+{
+template
+constexpr
+auto operator() (I &&i)  -> void;
+} iter_move;
+
+template
+using iter_rvalue_reference_t = decltype(iter_move(declval()));
+
+template
+concept same_as = true;
+
+template
+concept readable_concept_ =
+same_as, iter_rvalue_reference_t>;
+
+template
+concept indirectly_readable =
+readable_concept_>;
+
+template
+using indirect_result_t =
+enable_if_t,
+invoke_result_t>>;
+
+template
+concept transformable =
+   (!is_void>::value);
+
+template
+requires transformable
+constexpr void transform(I, Fun)
+{
+}
+
+void foo()
+{
+struct B {};
+(void) transform((B*)nullptr, [](B) {return 0; });
+}

base-commit: 928116e94a5a8a995dffd926af58abfa7286e78e
-- 
2.45.2



[pushed] c++: consteval propagation and templates [PR115986]

2024-07-27 Thread Jason Merrill
Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

Here the call to e() makes us decide to check d() for escalation at EOF, but
while checking it we try to fold_immediate 0_c, and get confused by the
template trees.  Let's not mess with escalation for function templates.

PR c++/115986

gcc/cp/ChangeLog:

* cp-gimplify.cc (remember_escalating_expr): Skip function
templates.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/consteval-prop21.C: New test.
---
 gcc/cp/cp-gimplify.cc |  4 
 gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C | 17 +
 2 files changed, 21 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C

diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index e6629dea5fd..6a5e4cf62ca 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -53,6 +53,10 @@ static GTY(()) hash_set *deferred_escalating_exprs;
 static void
 remember_escalating_expr (tree t)
 {
+  if (uses_template_parms (t))
+/* Templates don't escalate, and cp_fold_immediate can get confused by
+   other template trees in the function body (c++/115986).  */
+return;
   if (!deferred_escalating_exprs)
 deferred_escalating_exprs = hash_set::create_ggc (37);
   deferred_escalating_exprs->add (t);
diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C 
b/gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C
new file mode 100644
index 000..debbda4f425
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/consteval-prop21.C
@@ -0,0 +1,17 @@
+// PR c++/115986
+// { dg-do compile { target c++20 } }
+
+template 
+constexpr int b(T) {
+  return 0;
+}
+consteval __uint128_t operator"" _c(const char*) { return 0; }
+constexpr char e() {
+  long f = true ? 0 : b(long(1));
+  return b(f);
+}
+template 
+void d() {
+  0_c;
+  static_assert(e());
+}

base-commit: 928116e94a5a8a995dffd926af58abfa7286e78e
-- 
2.45.2



Re: *** SPAM *** [Patch, fortran] PR79685 - [12/13/14/15 Regression] ICE on valid code in gfc_match_structure_constructor

2024-07-27 Thread Paul Richard Thomas
Hi Mikael,

You were absolutely right. I looked at the caller and "just didn't get it".
Thanks. I will resubmit when I get back from a business trip.

Cordialement

Paul



On Sat, 27 Jul 2024 at 12:35, Mikael Morin  wrote:

> Hello,
>
> Le 27/07/2024 à 11:25, Paul Richard Thomas a écrit :
> > This patch is straightforward but I am still puzzled as to why it is
> > necessary for the particular case. Having looked at all the other chunks
> > of frontend code involving use renaming, it seems that the process just
> > works everywhere else. I tried putting the new code in gfc_find_symtree
> > but it caused some regressions unless I pinned it down to the specific
> > case of a structure constructor.
> >
> I think it works as expected, symtrees have the local names, and symbols
> the original name, so if all that is available is the symbol, name
> lookup may not work correctly with renaming.  And I think that there are
> other places where it happens.
>
> In this case, it seems the caller can provide the local name, which
> would avoid processing the use statements.  Did you try that?
>
> Mikael
>


[PATCH 1/2] testsuite: fix dg-do ordering wrt dg-require-*

2024-07-27 Thread Sam James
Per gccint, dg-do must precede dg-require-effective-target or
dg-require-support. Fix a handful of deviant cases.

gcc/testsuite/ChangeLog:

* gcc.dg/pr25521.c: Fix dg-do directive order.
* gcc.dg/vect/vect-simd-clone-19.c: Likewise.
* gcc.target/arm/stack-protector-7.c: Likewise.
* gcc.target/arm/stack-protector-8.c: Likewise.
* gcc.target/powerpc/pr93122.c: Likewise.

libstdc++-v3/ChangeLog:

PR libstdc++/110572
* testsuite/18_support/type_info/110572.cc: Fix dg-do directive order.
---
Simple dejagnu directive fixes. OK?

 gcc/testsuite/gcc.dg/pr25521.c| 2 +-
 gcc/testsuite/gcc.dg/vect/vect-simd-clone-19.c| 2 +-
 gcc/testsuite/gcc.target/arm/stack-protector-7.c  | 2 +-
 gcc/testsuite/gcc.target/arm/stack-protector-8.c  | 2 +-
 gcc/testsuite/gcc.target/powerpc/pr93122.c| 2 +-
 libstdc++-v3/testsuite/18_support/type_info/110572.cc | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr25521.c b/gcc/testsuite/gcc.dg/pr25521.c
index 82b4cd88ec05..cd1b90085e11 100644
--- a/gcc/testsuite/gcc.dg/pr25521.c
+++ b/gcc/testsuite/gcc.dg/pr25521.c
@@ -1,8 +1,8 @@
 /* PR middle-end/25521 - place `const volatile' objects in read-only
sections.
 
-   { dg-require-effective-target elf }
{ dg-do compile }
+   { dg-require-effective-target elf }
{ dg-skip-if "" { ! const_volatile_readonly_section } } */
 
 const volatile int foo = 30;
diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-19.c 
b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-19.c
index e7ed56ca7547..46d25526479d 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-19.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-19.c
@@ -1,5 +1,5 @@
-/* { dg-require-effective-target vect_simd_clones } */
 /* { dg-do compile } */
+/* { dg-require-effective-target vect_simd_clones } */
 
 int __attribute__ ((__simd__, const)) fn (int);
 
diff --git a/gcc/testsuite/gcc.target/arm/stack-protector-7.c 
b/gcc/testsuite/gcc.target/arm/stack-protector-7.c
index 2173bc5a35a0..23207fd98c84 100644
--- a/gcc/testsuite/gcc.target/arm/stack-protector-7.c
+++ b/gcc/testsuite/gcc.target/arm/stack-protector-7.c
@@ -1,6 +1,6 @@
+/* { dg-do compile } */
 /* { dg-require-effective-target arm_hard_vfp_ok }  */
 /* { dg-require-effective-target arm_arch_v7a_ok } */
-/* { dg-do compile } */
 /* { dg-options "-march=armv7-a -mfpu=vfp -fstack-protector-all -Os 
-mstack-protector-guard=tls -mstack-protector-guard-offset=1296 -mtp=cp15" } */
 
 #include "stack-protector-5.c"
diff --git a/gcc/testsuite/gcc.target/arm/stack-protector-8.c 
b/gcc/testsuite/gcc.target/arm/stack-protector-8.c
index ea5ef3211678..165f34706cc4 100644
--- a/gcc/testsuite/gcc.target/arm/stack-protector-8.c
+++ b/gcc/testsuite/gcc.target/arm/stack-protector-8.c
@@ -1,6 +1,6 @@
+/* { dg-do compile } */
 /* { dg-require-effective-target arm_hard_vfp_ok }  */
 /* { dg-require-effective-target arm_arch_v7a_ok } */
-/* { dg-do compile } */
 /* { dg-error "needs a hardware TLS register" "missing error when using TLS 
stack protector without hardware TLS register" { target *-*-* } 0 } */
 /* { dg-options "-fstack-protector-all -Os -mstack-protector-guard=tls 
-mtp=soft" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/pr93122.c 
b/gcc/testsuite/gcc.target/powerpc/pr93122.c
index 97bcb0cea5ff..42d1d94ba15f 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr93122.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr93122.c
@@ -1,6 +1,6 @@
 /* PR target/93122 */
-/* { dg-require-effective-target power10_ok } */
 /* { dg-do compile { target lp64 } } */
+/* { dg-require-effective-target power10_ok } */
 /* { dg-options "-fstack-clash-protection -mprefixed -mdejagnu-cpu=power10" } 
*/
 
 void bar (char *);
diff --git a/libstdc++-v3/testsuite/18_support/type_info/110572.cc 
b/libstdc++-v3/testsuite/18_support/type_info/110572.cc
index 64081879b77d..f727653adfb1 100644
--- a/libstdc++-v3/testsuite/18_support/type_info/110572.cc
+++ b/libstdc++-v3/testsuite/18_support/type_info/110572.cc
@@ -1,7 +1,7 @@
 // { dg-options "-static-libstdc++" }
+// { dg-do link }
 // { dg-require-static-libstdcxx }
 // { dg-require-cpp-feature-test __cpp_rtti }
-// { dg-do link }
 
 #include 
 

-- 
2.45.2



[PATCH 2/2] testsuite: fix dg-add-options vs. dg-options ordering

2024-07-27 Thread Sam James
Per gccint, dg-add-options must be placed after all dg-options directives.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/cmpmem-2.c: Fix dg-add-options order.
---
Simple dejagnu directive fixes. OK?

 gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c
index c782cc6c6e6e..fdb402a787b4 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c
@@ -1,6 +1,6 @@
 /* { dg-do run { target { riscv_v } } } */
-/* { dg-add-options riscv_v } */
 /* { dg-options "-O2 -mrvv-max-lmul=dynamic" } */
+/* { dg-add-options riscv_v } */
 
 #include 
 
-- 
2.45.2



[r15-2362 Regression] FAIL: g++.dg/cpp2a/consteval-prop21.C -std=c++26 (test for excess errors) on Linux/x86_64

2024-07-27 Thread haochen.jiang
On Linux/x86_64,

a9e9f772c7488ac0c09dd92f28890bdab939771a is the first bad commit
commit a9e9f772c7488ac0c09dd92f28890bdab939771a
Author: Jason Merrill 
Date:   Fri Jul 26 17:20:18 2024 -0400

c++: consteval propagation and templates [PR115986]

caused

FAIL: g++.dg/cpp2a/consteval-prop21.C  -std=c++20 (test for excess errors)
FAIL: g++.dg/cpp2a/consteval-prop21.C  -std=c++23 (test for excess errors)
FAIL: g++.dg/cpp2a/consteval-prop21.C  -std=c++26 (test for excess errors)

with GCC configured with

../../gcc/configure 
--prefix=/export/users/haochenj/src/gcc-bisect/master/master/r15-2362/usr 
--enable-clocale=gnu --with-system-zlib --with-demangler-in-ld 
--with-fpmath=sse --enable-languages=c,c++,fortran --enable-cet --without-isl 
--enable-libmpx x86_64-linux --disable-bootstrap

To reproduce:

$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=g++.dg/cpp2a/consteval-prop21.C 
--target_board='unix{-m32}'"
$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=g++.dg/cpp2a/consteval-prop21.C --target_board='unix{-m32\ 
-march=cascadelake}'"

(Please do not reply to this email, for question about this report, contact me 
at haochen dot jiang at intel.com.)
(If you met problems with cascadelake related, disabling AVX512F in command 
line might save that.)
(However, please make sure that there is no potential problems with AVX512.)


[PATCH v1] Widening-Mul: Try .SAT_SUB for PLUS_EXPR when one op is IMM

2024-07-27 Thread pan2 . li
From: Pan Li 

After add the matching for .SAT_SUB when one op is IMM,  there
will be a new root PLUS_EXPR for the .SAT_SUB pattern.  For example,

Form 3:
  #define DEF_SAT_U_SUB_IMM_FMT_3(T, IMM) \
  T __attribute__((noinline)) \
  sat_u_sub_imm##IMM##_##T##_fmt_3 (T x)  \
  {   \
return x >= IMM ? x - IMM : 0;\
  }

DEF_SAT_U_SUB_IMM_FMT_3(uint64_t, 11)

And then we will have gimple before widening-mul as below.  Thus,  try
the .SAT_SUB for the PLUS_EXPR.

   4   │ __attribute__((noinline))
   5   │ uint64_t sat_u_sub_imm11_uint64_t_fmt_3 (uint64_t x)
   6   │ {
   7   │   long unsigned int _1;
   8   │   uint64_t _3;
   9   │
  10   │[local count: 1073741824]:
  11   │   _1 = MAX_EXPR ;
  12   │   _3 = _1 + 18446744073709551605;
  13   │   return _3;
  14   │
  15   │ }

The below test suites are passed for this patch.
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

gcc/ChangeLog:

* tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children):
Try .SAT_SUB for PLUS_EXPR case.

Signed-off-by: Pan Li 
---
 gcc/tree-ssa-math-opts.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index ac86be8eb94..8d96a4c964b 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -6129,6 +6129,7 @@ math_opts_dom_walker::after_dom_children (basic_block bb)
 
case PLUS_EXPR:
  match_unsigned_saturation_add (&gsi, as_a (stmt));
+ match_unsigned_saturation_sub (&gsi, as_a (stmt));
  /* fall-through  */
case MINUS_EXPR:
  if (!convert_plusminus_to_widen (&gsi, stmt, code))
-- 
2.34.1



[PATCH 1/2] middle-end: Remove PROP_no_crit_edges [PR116114]

2024-07-27 Thread Andrew Pinski
PROP_no_crit_edges was made checked by r8-2993-ga7976089dba5e2 by
doing an explict splitting critical edges directly in PRE.
So let's remove it.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Note this depends on 
https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658447.html .

gcc/ChangeLog:

PR middle-end/116114
* function.h (PROP_no_crit_edges): Delete.
* passes.cc (dump_properties): Remove testing of PROP_no_crit_edges
* tree-cfg.cc (pass_data_split_crit_edges): Don't set PROP_no_crit_edges
for properties provided.
* tree-ssa-sink.cc (pass_data_sink_code): Remove comment about
PROP_no_crit_edges.

Signed-off-by: Andrew Pinski 
---
 gcc/function.h   | 2 +-
 gcc/passes.cc| 2 --
 gcc/tree-cfg.cc  | 2 +-
 gcc/tree-ssa-sink.cc | 2 --
 4 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/gcc/function.h b/gcc/function.h
index c2c1b808eb1..f0f48648504 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -251,7 +251,7 @@ public:
 #define PROP_cfg   (1 << 3)
 #define PROP_objsz (1 << 4)/* object sizes computed */
 #define PROP_ssa   (1 << 5)
-#define PROP_no_crit_edges  (1 << 6)
+/* UNUSED  (1 << 6) */
 #define PROP_rtl   (1 << 7)
 #define PROP_gimple_lomp   (1 << 8)/* lowered OpenMP directives */
 #define PROP_cfglayout (1 << 9)/* cfglayout mode on RTL */
diff --git a/gcc/passes.cc b/gcc/passes.cc
index bf91befe074..c494c76808b 100644
--- a/gcc/passes.cc
+++ b/gcc/passes.cc
@@ -3178,8 +3178,6 @@ dump_properties (FILE *dump, unsigned int props)
 fprintf (dump, "PROP_cfg\n");
   if (props & PROP_ssa)
 fprintf (dump, "PROP_ssa\n");
-  if (props & PROP_no_crit_edges)
-fprintf (dump, "PROP_no_crit_edges\n");
   if (props & PROP_rtl)
 fprintf (dump, "PROP_rtl\n");
   if (props & PROP_gimple_lomp)
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 32b0d3b356e..3b0c7c4ba53 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -9495,7 +9495,7 @@ const pass_data pass_data_split_crit_edges =
   OPTGROUP_NONE, /* optinfo_flags */
   TV_TREE_SPLIT_EDGES, /* tv_id */
   PROP_cfg, /* properties_required */
-  PROP_no_crit_edges, /* properties_provided */
+  0, /* properties_provided */
   0, /* properties_destroyed */
   0, /* todo_flags_start */
   0, /* todo_flags_finish */
diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc
index 737638591db..ad5dd83e43d 100644
--- a/gcc/tree-ssa-sink.cc
+++ b/gcc/tree-ssa-sink.cc
@@ -799,8 +799,6 @@ const pass_data pass_data_sink_code =
   "sink", /* name */
   OPTGROUP_NONE, /* optinfo_flags */
   TV_TREE_SINK, /* tv_id */
-  /* PROP_no_crit_edges is ensured by running split_edges_for_insertion in
- pass_data_sink_code::execute ().  */
   ( PROP_cfg | PROP_ssa ), /* properties_required */
   0, /* properties_provided */
   0, /* properties_destroyed */
-- 
2.43.0



[PATCH 2/2] middle-end: Move the function current properties over to a .def file [PR116118]

2024-07-27 Thread Andrew Pinski
While doing some other cleanups with the properties I noticed that 
debug_properties
was not updated for some of the new properties. So instead of just updating the 
function,
this moves the properties over to its own .def file so we don't need to update 
this nor will
have a conflict in the bit ordering either.

For now I just used an `enum class` for the enum that holds the bit number of 
each property.
Later on this might be changed to a normal enum and only use that instead. But 
that won't be
until we require C++17 since `folding expressions` make this code much simplier.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR middle-end/116118
* function.h (PROP_bitnum): New enum class.
(function_prop_type): New typedef.
(PROP_gimple_any): Remove.
(PROP_gimple_lcf): Remove.
(PROP_gimple_leh): Remove.
(PROP_cfg): Remove.
(PROP_objsz): Remove.
(PROP_ssa): Remove.
(PROP_rtl): Remove.
(PROP_gimple_lomp): Remove.
(PROP_cfglayout): Remove.
(PROP_gimple_lcx): Remove.
(PROP_loops): Remove.
(PROP_gimple_lvec): Remove.
(PROP_gimple_eomp): Remove.
(PROP_gimple_lva): Remove.
(PROP_gimple_opt_math): Remove.
(PROP_gimple_lomp_dev): Remove.
(PROP_rtl_split_insns): Remove.
(PROP_loop_opts_done): Remove.
(PROP_assumptions_done): Remove.
(PROP_gimple_lbitint): Remove.
(enum PROP_bit): New.
(struct function): Use function_prop_type instead of `unsigned int`
for the properties.
* passes.cc (debug_properties): Update to use function_prop_type.
(dump_properties): Likewise. Also don't directly print the properties,
use an array.
* ir-prop.def: New file.

Signed-off-by: Andrew Pinski 
---
 gcc/function.h  | 47 ---
 gcc/ir-prop.def | 45 +
 gcc/passes.cc   | 45 +++--
 3 files changed, 84 insertions(+), 53 deletions(-)
 create mode 100644 gcc/ir-prop.def

diff --git a/gcc/function.h b/gcc/function.h
index f0f48648504..9a678741f6c 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -243,34 +243,27 @@ public:
   (current_function_dynamic_stack_size != 0   \
|| current_function_has_unbounded_dynamic_stack_size)
 
+/* Pass properties set on function::curr_properties.  */
+enum class PROP_bitnum
+{
+#define PROP(a) PROP_BIT_##a ,
+#include "ir-prop.def"
+PROP_BIT_end
+};
+
+typedef unsigned int function_prop_type;
+/* Make sure current_properties has enough bits for the properties. */
+static_assert ((size_t)PROP_bitnum::PROP_BIT_end
+   <= (sizeof(function_prop_type) * CHAR_BIT),
+  "too many properties for prop type");
 
 /* Pass properties set on function::curr_properties.  */
-#define PROP_gimple_any(1 << 0)/* entire gimple 
grammar */
-#define PROP_gimple_lcf(1 << 1)/* lowered control flow 
*/
-#define PROP_gimple_leh(1 << 2)/* lowered eh */
-#define PROP_cfg   (1 << 3)
-#define PROP_objsz (1 << 4)/* object sizes computed */
-#define PROP_ssa   (1 << 5)
-/* UNUSED  (1 << 6) */
-#define PROP_rtl   (1 << 7)
-#define PROP_gimple_lomp   (1 << 8)/* lowered OpenMP directives */
-#define PROP_cfglayout (1 << 9)/* cfglayout mode on RTL */
-#define PROP_gimple_lcx(1 << 10)   /* lowered complex */
-#define PROP_loops (1 << 11)   /* preserve loop structures */
-#define PROP_gimple_lvec   (1 << 12)   /* lowered vector */
-#define PROP_gimple_eomp   (1 << 13)   /* no OpenMP directives */
-#define PROP_gimple_lva(1 << 14)   /* No va_arg internal 
function.  */
-#define PROP_gimple_opt_math   (1 << 15)   /* Disable canonicalization
-  of math functions; the
-  current choices have
-  been optimized.  */
-#define PROP_gimple_lomp_dev   (1 << 16)   /* done omp_device_lower */
-#define PROP_rtl_split_insns   (1 << 17)   /* RTL has insns split.  */
-#define PROP_loop_opts_done(1 << 18)   /* SSA loop optimizations
-  have completed.  */
-#define PROP_assumptions_done  (1 << 19)   /* Assume function kept
-  around.  */
-#define PROP_gimple_lbitint(1 << 20)   /* lowered large _BitInt */
+enum PROP_bit : function_prop_type
+{
+#define PROP(a) PROP_##a = \
+   ((function_prop_type)1) << 
(function_prop_type)PROP_bitnum::PROP_BIT_##a,
+#include "ir-prop.def"
+};
 
 #define PROP_gimple \
   (PROP_gimple_any |

Re: [PATCH 2/2] middle-end: Move the function current properties over to a .def file [PR116118]

2024-07-27 Thread Richard Biener



> Am 28.07.2024 um 06:41 schrieb Andrew Pinski :
> 
> While doing some other cleanups with the properties I noticed that 
> debug_properties
> was not updated for some of the new properties. So instead of just updating 
> the function,
> this moves the properties over to its own .def file so we don't need to 
> update this nor will
> have a conflict in the bit ordering either.
> 
> For now I just used an `enum class` for the enum that holds the bit number of 
> each property.
> Later on this might be changed to a normal enum and only use that instead. 
> But that won't be
> until we require C++17 since `folding expressions` make this code much 
> simplier.
> 
> Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Ok for both.  Can you check the internals manual if there’s any updates needed?

Thanks,
Richard 

> gcc/ChangeLog:
> 
>PR middle-end/116118
>* function.h (PROP_bitnum): New enum class.
>(function_prop_type): New typedef.
>(PROP_gimple_any): Remove.
>(PROP_gimple_lcf): Remove.
>(PROP_gimple_leh): Remove.
>(PROP_cfg): Remove.
>(PROP_objsz): Remove.
>(PROP_ssa): Remove.
>(PROP_rtl): Remove.
>(PROP_gimple_lomp): Remove.
>(PROP_cfglayout): Remove.
>(PROP_gimple_lcx): Remove.
>(PROP_loops): Remove.
>(PROP_gimple_lvec): Remove.
>(PROP_gimple_eomp): Remove.
>(PROP_gimple_lva): Remove.
>(PROP_gimple_opt_math): Remove.
>(PROP_gimple_lomp_dev): Remove.
>(PROP_rtl_split_insns): Remove.
>(PROP_loop_opts_done): Remove.
>(PROP_assumptions_done): Remove.
>(PROP_gimple_lbitint): Remove.
>(enum PROP_bit): New.
>(struct function): Use function_prop_type instead of `unsigned int`
>for the properties.
>* passes.cc (debug_properties): Update to use function_prop_type.
>(dump_properties): Likewise. Also don't directly print the properties,
>use an array.
>* ir-prop.def: New file.
> 
> Signed-off-by: Andrew Pinski 
> ---
> gcc/function.h  | 47 ---
> gcc/ir-prop.def | 45 +
> gcc/passes.cc   | 45 +++--
> 3 files changed, 84 insertions(+), 53 deletions(-)
> create mode 100644 gcc/ir-prop.def
> 
> diff --git a/gcc/function.h b/gcc/function.h
> index f0f48648504..9a678741f6c 100644
> --- a/gcc/function.h
> +++ b/gcc/function.h
> @@ -243,34 +243,27 @@ public:
>   (current_function_dynamic_stack_size != 0   \
>|| current_function_has_unbounded_dynamic_stack_size)
> 
> +/* Pass properties set on function::curr_properties.  */
> +enum class PROP_bitnum
> +{
> +#define PROP(a) PROP_BIT_##a ,
> +#include "ir-prop.def"
> +PROP_BIT_end
> +};
> +
> +typedef unsigned int function_prop_type;
> +/* Make sure current_properties has enough bits for the properties. */
> +static_assert ((size_t)PROP_bitnum::PROP_BIT_end
> +<= (sizeof(function_prop_type) * CHAR_BIT),
> +   "too many properties for prop type");
> 
> /* Pass properties set on function::curr_properties.  */
> -#define PROP_gimple_any(1 << 0)/* entire gimple grammar */
> -#define PROP_gimple_lcf(1 << 1)/* lowered control flow */
> -#define PROP_gimple_leh(1 << 2)/* lowered eh */
> -#define PROP_cfg(1 << 3)
> -#define PROP_objsz(1 << 4)/* object sizes computed */
> -#define PROP_ssa(1 << 5)
> -/* UNUSED(1 << 6) */
> -#define PROP_rtl(1 << 7)
> -#define PROP_gimple_lomp(1 << 8)/* lowered OpenMP directives */
> -#define PROP_cfglayout(1 << 9)/* cfglayout mode on RTL */
> -#define PROP_gimple_lcx(1 << 10)   /* lowered complex */
> -#define PROP_loops(1 << 11)/* preserve loop structures */
> -#define PROP_gimple_lvec(1 << 12)   /* lowered vector */
> -#define PROP_gimple_eomp(1 << 13)   /* no OpenMP directives */
> -#define PROP_gimple_lva(1 << 14)   /* No va_arg internal 
> function.  */
> -#define PROP_gimple_opt_math(1 << 15)/* Disable canonicalization
> -   of math functions; the
> -   current choices have
> -   been optimized.  */
> -#define PROP_gimple_lomp_dev(1 << 16)/* done omp_device_lower */
> -#define PROP_rtl_split_insns(1 << 17)/* RTL has insns split.  */
> -#define PROP_loop_opts_done(1 << 18)/* SSA loop optimizations
> -   have completed.  */
> -#define PROP_assumptions_done(1 << 19)/* Assume function kept
> -   around.  */
> -#define PROP_gimple_lbitint(1 << 20)   /* lowered large _BitInt */
> +enum PROP_bit : function_prop_type
> +{
> +#define PROP(a) PROP_##a = \
> +((function_prop_type)1) << (function_prop_type)PROP_bitnum::PROP_BIT_##a,
> +#include "ir-prop.def"
> +};
> 
> #define PROP_gimple \
>   (PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh

Re: [PATCH 2/2] testsuite: fix dg-add-options vs. dg-options ordering

2024-07-27 Thread Richard Biener



> Am 28.07.2024 um 01:34 schrieb Sam James :
> 
> Per gccint, dg-add-options must be placed after all dg-options directives.
> 
> gcc/testsuite/ChangeLog:
> 
>* gcc.target/riscv/rvv/base/cmpmem-2.c: Fix dg-add-options order.

Ok for both patches

Richard 

> ---
> Simple dejagnu directive fixes. OK?
> 
> gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c 
> b/gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c
> index c782cc6c6e6e..fdb402a787b4 100644
> --- a/gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c
> +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/cmpmem-2.c
> @@ -1,6 +1,6 @@
> /* { dg-do run { target { riscv_v } } } */
> -/* { dg-add-options riscv_v } */
> /* { dg-options "-O2 -mrvv-max-lmul=dynamic" } */
> +/* { dg-add-options riscv_v } */
> 
> #include 
> 
> --
> 2.45.2
>