[gcc r14-9681] libgfortran: Fix file position after ENDFILE statement.

2024-03-26 Thread Jerry DeLisle via Gcc-cvs
https://gcc.gnu.org/g:41e767c482fc903ca5d54014b034c7526dbf8f1c

commit r14-9681-g41e767c482fc903ca5d54014b034c7526dbf8f1c
Author: Jerry DeLisle 
Date:   Tue Mar 26 16:44:17 2024 -0700

libgfortran: Fix file position after ENDFILE statement.

PR libfortran/107031

libgfortran/ChangeLog:

* io/file_pos.c (st_endfile): Remove call to next_record().

gcc/testsuite/ChangeLog:

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

Diff:
---
 gcc/testsuite/gfortran.dg/endfile_5.f90 | 30 ++
 libgfortran/io/file_pos.c   |  1 -
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/endfile_5.f90 
b/gcc/testsuite/gfortran.dg/endfile_5.f90
new file mode 100644
index 000..90eaa6b2e5b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/endfile_5.f90
@@ -0,0 +1,30 @@
+! { dg-do run }
+! PR107031 Check that endfile truncates at end of record 5.
+program test_truncate
+integer :: num_rec, tmp, i, nr, j
+open(10, file="in.dat", action='readwrite')
+
+do i=1,10
+  write(10, *) i
+end do
+
+rewind (10)
+
+num_rec = 5
+i = 1
+ioerr = 0
+do while (i <= num_rec .and. ioerr == 0)
+read(10, *, iostat=ioerr) tmp
+i = i + 1
+enddo
+endfile(10)
+rewind (10)
+i = 0
+ioerr = 0
+do while (i <= num_rec + 1 .and. ioerr == 0)
+  read(10, *, iostat=ioerr) j
+  i = i + 1
+end do
+close(10, status='delete')
+if (i - 1 /= 5) stop 1
+end program test_truncate
diff --git a/libgfortran/io/file_pos.c b/libgfortran/io/file_pos.c
index 2bc05b293f8..d169961f997 100644
--- a/libgfortran/io/file_pos.c
+++ b/libgfortran/io/file_pos.c
@@ -352,7 +352,6 @@ st_endfile (st_parameter_filepos *fpp)
  dtp.common = fpp->common;
  memset (, 0, sizeof (dtp.u.p));
  dtp.u.p.current_unit = u;
- next_record (, 1);
}
 
   unit_truncate (u, stell (u->s), >common);


[gcc r14-9679] libstdc++: fix _V badname in

2024-03-26 Thread Arsen Arsenović via Libstdc++-cvs
https://gcc.gnu.org/g:ac5d63a46d78cded2cd4c41a615728b8e46b540f

commit r14-9679-gac5d63a46d78cded2cd4c41a615728b8e46b540f
Author: Arsen Arsenović 
Date:   Sat Mar 23 16:14:33 2024 +0100

libstdc++: fix _V badname in 

libstdc++-v3/ChangeLog:

* include/std/generator: Fix _V badname.

Diff:
---
 libstdc++-v3/include/std/generator | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/include/std/generator 
b/libstdc++-v3/include/std/generator
index 87983ee5e7c..2d1dcced1e5 100644
--- a/libstdc++-v3/include/std/generator
+++ b/libstdc++-v3/include/std/generator
@@ -76,14 +76,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @headerfile generator
* @since C++23
*/
-  template
+  template
 class generator;
 
   /// @cond undocumented
   namespace __gen
   {
 /// _Reference type for a generator whose reference (first argument) and
-/// value (second argument) types are _Ref and _V.
+/// value (second argument) types are _Ref and _Val.
 template
 using _Reference_t = __conditional_t,
 _Ref&&, _Ref>;
@@ -642,14 +642,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   } // namespace __gen
   /// @endcond
 
-  template
+  template
 class generator
-  : public ranges::view_interface>
+  : public ranges::view_interface>
 {
-  using _Value = __conditional_t, remove_cvref_t<_Ref>, _V>;
+  using _Value = __conditional_t,
+remove_cvref_t<_Ref>,
+_Val>;
   static_assert(__gen::_Cv_unqualified_object<_Value>,
"Generator value must be a cv-unqualified object type");
-  using _Reference = __gen::_Reference_t<_Ref, _V>;
+  using _Reference = __gen::_Reference_t<_Ref, _Val>;
   static_assert(is_reference_v<_Reference>
|| (__gen::_Cv_unqualified_object<_Reference>
&& copy_constructible<_Reference>),
@@ -737,8 +739,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   bool _M_began = false;
 };
 
-  template
-struct generator<_Ref, _V, _Alloc>::_Iterator
+  template
+struct generator<_Ref, _Val, _Alloc>::_Iterator
 {
   using value_type = _Value;
   using difference_type = ptrdiff_t;


[gcc/microsoft/heads/main] (420 commits) Merge commit 'ecd2c373720af214f20671f9e7d760548b51ef4a' int

2024-03-26 Thread Eugene Rozenfeld via Gcc-cvs
The branch 'microsoft/heads/main' was updated to point to:

 b707d632683... Merge commit 'ecd2c373720af214f20671f9e7d760548b51ef4a' int

It previously pointed to:

 7c61ce995ef... Merge commit 'fd07a29e39f5347d6cef3e7042a32306f97a1719' int

Diff:

Summary of changes (added commits):
---

  b707d63... Merge commit 'ecd2c373720af214f20671f9e7d760548b51ef4a' int
  ecd2c37... Daily bump. (*)
  bb04a11... Daily bump. (*)
  a684581... PR modula2/11 trunc float malformed error cause ICE (*)
  c8a343f... PR modula2/114443 missing quote cause ICE (*)
  80a0cb3... analyzer: fix ICE and false positive with -Wanalyzer-deref- (*)
  2e4b337... hppa: Fix LO_SUM DLTIND14R address support in PRINT_OPERAND (*)
  5435850... libstdc++: Disable std::formatter specializations (LWG 3944 (*)
  3763fb8... libstdc++: Add __is_in_place_index_v helper and use it in < (*)
  f4605c5... libstdc++: Use std::type_identity_t in  as per (*)
  4a46a48... bitint: Fix bitfield loads in handle_cast [PR114433] (*)
  f92cf8c... bitint: Handle complex types in build_bitint_stmt_ssa_confl (*)
  8fc5593... predcom: Punt for steps which aren't multiples of access si (*)
  7a01cc7... xtensa: Add supplementary split pattern for "*addsubx" (*)
  e898586... Daily bump. (*)
  c2e28df... libstdc++: Destroy allocators in re-inserted container node (*)
  142cc4c... libstdc++: Constrain std::vector default constructor [PR113 (*)
  8539c56... libstdc++: Use feature test macros in   (*)
  90788dd... libstdc++: Regenerate  in maintainer mode (*)
  d1b8c22... libstdc++: Update docs on build process and generated files (*)
  ef2efc5... libstdc++: Fix Python scripts to output the correct filenam (*)
  f511854... libstdc++: Fix typos in MemoryChecker assertion messages in (*)
  16afbd9... libstdc++: Begin lifetime of storage in std::vector [ (*)
  c7a774e... analyzer: fixes to __atomic_{exchange,load,store} [PR114286 (*)
  4adb1a5... testsuite, Darwin: Use the IOKit framework in framework-1.c (*)
  71a44fa... libstdc++: Sync the atomic_link_flags implementation with G (*)
  e47330d... libstdc++, Darwin: Do not use dev/null as the file for exec (*)
  e0e9499... tree-optimization/114151 - revert PR114074 fix (*)
  1f25771... arc: Fix up arc_setup_incoming_varargs [PR114175] (*)
  c1fd458... LoongArch: Fix C23 (...) functions returning large aggregat (*)
  167ec6d... arm: [MVE intrinsics] Fix support for loads [PR target/1143 (*)
  a185d8a... alpha: Fix alpha_setup_incoming_varargs [PR114175] (*)
  8f85b46... rs6000: Fix up setup_incoming_varargs [PR114175] (*)
  8959ab6... openmp: Make c_omp_check_loop_binding_exprs diagnostics tra (*)
  94c3508... tree-optimization/114375 - disallow SLP discovery of permut (*)
  9eeca77... [PATCH v5 1/1] RISC-V: Add support for XCVbi extension in C (*)
  d91a0ce... [PATCH] RISC-V: Add XiangShan Nanhu microarchitecture. (*)
  c4845ed... c++: Fix handling of no-linkage decls for modules (*)
  2340973... Daily bump. (*)
  9ee19f9... c-c++-common/Wrestrict.c: fix some typos and enable for LLP (*)
  1579394... analyzer: fix ICEs due to sloppy types in bounds-checking [ (*)
  3c2827d... analyzer: support null operands in remove_ssa_names (*)
  dda96a9... libstdc++: Fix N3344 behavior on _Safe_iterator::_M_can_adv (*)
  5f6e085... libstdc++: Fix _Safe_local_iterator<>::_M_valid_range (*)
  b96c543... i386: Unify {general,timode}_scalar_chain::convert_op [PR11 (*)
  3be2b8f... Fortran: error recovery in frontend optimization [PR103715] (*)
  9316d02... testsuite: Turn errors back into warnings in arm/acle/cde-m (*)
  d2029bb... PR modula2/114380 Incorrect type specified in an error mess (*)
  3e3ad8e... Update gcc fr.po, sv.po (*)
  fd776d0... gcc_update: Add missing generated files (*)
  6cb5ef3... testsuite: Fix excess errors for new modules testcases on p (*)
  dfc9d1c... Add missing config/i386/zn4zn5.md file (*)
  d0aa0af... Add AMD znver5 processor enablement with scheduler model (*)
  9361f19... avr.md - Tweak xor insn constraints. (*)
  58753db... testsuite: Define _POSIX_C_SOURCE for test (*)
  942d470... Add missing hf/bf patterns. (*)
  f0fda1a... hppa: Improve handling of REG+D addresses when generating P (*)
  27d2e93... Daily bump. (*)
  3f3f0b7... Fortran: fix for absent array argument passed to optional d (*)
  8064107... hppa: Fix complaint about non-delegitimized UNSPEC UNSPEC_T (*)
  07fad7a... libstdc++: Implement N3644 on _Safe_iterator<> [PR114316] (*)
  f065c58... PR modula2/114296 ICE when attempting to create a constant  (*)
  2d454f9... d: Merge upstream dmd, druntime 855353a1d9 (*)
  b5490af... Daily bump. (*)
  218d174... i386: Fix setup of incoming varargs for (...) functions whi (*)
  3e8323e... bitint: Fix up stores to large/huge _BitInt bitfields [PR11 (*)
  ead3075... c++: Check module attachment instead of just purview when n (*)
  5213047... libcc1: fix  include (*)
  53fb2cf... Daily bump. (*)
  a6dab19... libgcc: Fix quotient and/or remainder negation in __divmodb (*)
 

[gcc r14-9678] aarch64: Use constexpr for out-of-line statics

2024-03-26 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:5be2313bceea7b482c17ee730efe604b910800bd

commit r14-9678-g5be2313bceea7b482c17ee730efe604b910800bd
Author: Richard Sandiford 
Date:   Tue Mar 26 17:27:56 2024 +

aarch64: Use constexpr for out-of-line statics

GCC 4.8 complained about the use of const rather than constexpr
for out-of-line static constexprs.

gcc/
* config/aarch64/aarch64-feature-deps.h: Use constexpr for
out-of-line statics.

Diff:
---
 gcc/config/aarch64/aarch64-feature-deps.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-feature-deps.h 
b/gcc/config/aarch64/aarch64-feature-deps.h
index 3641badb82f..79126db8825 100644
--- a/gcc/config/aarch64/aarch64-feature-deps.h
+++ b/gcc/config/aarch64/aarch64-feature-deps.h
@@ -71,9 +71,9 @@ template struct info;
 static constexpr auto enable = flag | get_enable REQUIRES; \
 static constexpr auto explicit_on = enable | get_enable EXPLICIT_ON; \
   };   \
-  const aarch64_feature_flags info::flag;  \
-  const aarch64_feature_flags info::enable;\
-  const aarch64_feature_flags info::explicit_on; \
+  constexpr aarch64_feature_flags info::flag;  \
+  constexpr aarch64_feature_flags info::enable;
\
+  constexpr aarch64_feature_flags info::explicit_on; \
   constexpr info IDENT ()  \
   {\
 return info ();\


[gcc r14-9677] btf: Emit labels in DATASEC bts_offset entries.

2024-03-26 Thread Cupertino Miranda via Gcc-cvs
https://gcc.gnu.org/g:fa60ac549649655a3f55e69f83d2e97423d3eb5c

commit r14-9677-gfa60ac549649655a3f55e69f83d2e97423d3eb5c
Author: Cupertino Miranda 
Date:   Tue Mar 26 11:59:47 2024 +

btf: Emit labels in DATASEC bts_offset entries.

GCC was defining bts_offset entry to always contain 0.
When comparing with clang, the same entry is instead a label to the
respective variable or function. The assembler emits relocations for
those labels.

gcc/ChangeLog:
PR target/114431
* btfout.cc (get_name_for_datasec_entry): Add function.
(btf_asm_datasec_entry): Print label when possible.

gcc/testsuite/ChangeLog:
* gcc.dg/debug/btf/btf-datasec-1.c: Correct for new
implementation.
* gcc.dg/debug/btf/btf-datasec-2.c: Likewise
* gcc.dg/debug/btf/btf-pr106773.c: Likewise

Diff:
---
 gcc/btfout.cc  | 30 +-
 gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c |  6 --
 gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c |  7 --
 gcc/testsuite/gcc.dg/debug/btf/btf-pr106773.c  |  2 +-
 4 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/gcc/btfout.cc b/gcc/btfout.cc
index 7aabd99f3e7..2e2b3524e83 100644
--- a/gcc/btfout.cc
+++ b/gcc/btfout.cc
@@ -1014,13 +1014,41 @@ btf_asm_func_type (ctf_container_ref ctfc, 
ctf_dtdef_ref dtd, ctf_id_t id)
   btf_asm_type_ref ("btt_type", ctfc, get_btf_id (ref_id));
 }
 
+/* Collect the name for the DATASEC reference required to be output as a
+   symbol. */
+
+static const char *
+get_name_for_datasec_entry (ctf_container_ref ctfc, ctf_id_t ref_id)
+{
+  if (ref_id >= num_types_added + 1
+  && ref_id < num_types_added + num_vars_added + 1)
+{
+  /* Ref to a variable.  Should only appear in DATASEC entries.  */
+  ctf_id_t var_id = btf_relative_var_id (ref_id);
+  ctf_dvdef_ref dvd = ctfc->ctfc_vars_list[var_id];
+  return dvd->dvd_name;
+}
+  else if (ref_id >= num_types_added + num_vars_added + 1)
+{
+  /* Ref to a FUNC record.  */
+  size_t func_id = btf_relative_func_id (ref_id);
+  ctf_dtdef_ref ref_type = (*funcs)[func_id];
+  return get_btf_type_name (ref_type);
+}
+  return NULL;
+}
+
 /* Asm'out a variable entry following a BTF_KIND_DATASEC.  */
 
 static void
 btf_asm_datasec_entry (ctf_container_ref ctfc, struct btf_var_secinfo info)
 {
+  const char *symbol_name = get_name_for_datasec_entry (ctfc, info.type);
   btf_asm_type_ref ("bts_type", ctfc, info.type);
-  dw2_asm_output_data (4, info.offset, "bts_offset");
+  if (symbol_name == NULL)
+dw2_asm_output_data (4, info.offset, "bts_offset");
+  else
+dw2_asm_output_offset (4, symbol_name, NULL, "bts_offset");
   dw2_asm_output_data (4, info.size, "bts_size");
 }
 
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c 
b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
index 77df88648c5..8557c38c20d 100644
--- a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
@@ -19,8 +19,10 @@
 /* { dg-final { scan-assembler-times "0xf03\[\t \]+\[^\n\]*btt_info" 2 } } 
*/
 /* { dg-final { scan-assembler-times "0xf01\[\t \]+\[^\n\]*btt_info" 1 } } 
*/
 
-/* The offset entry for each variable in a DATSEC should be 0 at compile time. 
 */
-/* { dg-final { scan-assembler-times "0\[\t \]+\[^\n\]*bts_offset" 7 } } */
+/* The offset entry for each variable in a DATSEC should contain a label.  */
+/* { dg-final { scan-assembler-times ".4byte\[\t \]\[a-e\]\[\t 
\]+\[^\n\]*bts_offset" 5 } } */
+/* { dg-final { scan-assembler-times "my_cstruct\[\t \]+\[^\n\]*bts_offset" 1 
} } */
+/* { dg-final { scan-assembler-times "bigarr\[\t \]+\[^\n\]*bts_offset" 1 } } 
*/
 
 /* Check that strings for each DATASEC have been added to the BTF string 
table.  */
 /* { dg-final { scan-assembler-times "ascii \".data.0\"\[\t 
\]+\[^\n\]*btf_aux_string" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c 
b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c
index d6f3358d6fb..857d830e446 100644
--- a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-2.c
@@ -9,8 +9,11 @@
 /* { dg-final { scan-assembler-times " BTF_KIND_DATASEC 
'.foo_sec'\[\\r\\n\]+\[^\\r\\n\]*0xf01\[\t \]+\[^\n\]*btt_info" 1 } } */
 /* { dg-final { scan-assembler-times " BTF_KIND_DATASEC 
'.bar_sec'\[\\r\\n\]+\[^\\r\\n\]*0xf02\[\t \]+\[^\n\]*btt_info" 1 } } */
 
-/* Function entries should have offset and size of 0 at compile time.  */
-/* { dg-final { scan-assembler-times "0\[\t \]+\[^\n\]*bts_offset" 3 } } */
+/* Function entries should have offset with a label and size of 0 at compile 
time.  */
+/* { dg-final { scan-assembler-times "chacha\[\t \]+\[^\n\]*bts_offset" 1 } } 
*/
+/* { dg-final { scan-assembler-times "bar\[\t \]+\[^\n\]*bts_offset" 1 } } */
+/* { dg-final { scan-assembler-times "foo\[\t \]+\[^\n\]*bts_offset" 1 } } 

[gcc r14-9676] testsuite: Fix up pr111151.c testcase [PR114486]

2024-03-26 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:f536ea9cc3226793dc156952340f21e55b60c04e

commit r14-9676-gf536ea9cc3226793dc156952340f21e55b60c04e
Author: Jakub Jelinek 
Date:   Tue Mar 26 16:40:53 2024 +0100

testsuite: Fix up pr51.c testcase [PR114486]

Apparently I've somehow screwed up the adjustments of the originally tested
testcase, tweaked it so that in the second/third cases it actually see
a MAX_EXPR rather than COND_EXPR the MAX_EXPR has been optimized into,
and didn't update the expected value.

2024-03-26  Jakub Jelinek  

PR middle-end/51
PR testsuite/114486
* gcc.c-torture/execute/pr51.c (main): Fix up expected value for
f.

Diff:
---
 gcc/testsuite/gcc.c-torture/execute/pr51.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.c-torture/execute/pr51.c 
b/gcc/testsuite/gcc.c-torture/execute/pr51.c
index 89255d28054..063617f5b9c 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr51.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr51.c
@@ -11,7 +11,7 @@ main ()
   int d = (-__INT_MAX__ - 1) / 2;
   int e = 10;
   int f = (d * 2 > e * 5 ? d * 2 : e * 5) * 6;
-  if (f != 120)
+  if (f != 300)
 __builtin_abort ();
   int g = (-__INT_MAX__ - 1) / 2;
   int h = 0;


[gcc r14-9675] PR modula2/114478 isnormal builtin unavailable from m2

2024-03-26 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:b1af867d22e3108402c62f97d8fcd1df303c9dab

commit r14-9675-gb1af867d22e3108402c62f97d8fcd1df303c9dab
Author: Gaius Mulley 
Date:   Tue Mar 26 15:33:52 2024 +

PR modula2/114478 isnormal builtin unavailable from m2

This patch adds isnormal (and isgreater, isless, isgreaterequal,
islessequal, islessgreater, isunordered) c99 macro similar prototyped
builtins to m2.

gcc/m2/ChangeLog:

PR modula2/114478
* gm2-gcc/m2builtins.cc (struct builtin_macro_definition): New 
struct.
(lookup_builtin_macro): New function.
(m2builtins_BuildBuiltinTree): Rewrite to lookup builtin function
and builtin macro.
(lookup_builtin_function): New function.
(define_builtin): Rename parameter type to prototype push macro
definition to builtin_macros vector.
(define_builtin_ext): New function.
(define_builtin_math): New function.
(m2builtins_init): Add isgreater, isless, isgreaterequal,
islessequal, islessgreater, isunordered, isnormal to macro 
definitions.
* gm2-libs/Builtins.def (isgreater): New procedure function.
(isgreaterf): Ditto.
(isgreaterl): Ditto.
(isgreaterequal): Ditto.
(isgreaterequalf): Ditto.
(isgreaterequall): Ditto.
(isless): Ditto.
(islessf): Ditto.
(islessl): Ditto.
(islessequal): Ditto.
(islessequalf): Ditto.
(islessequall): Ditto.
(islessgreater): Ditto.
(islessgreaterf): Ditto.
(islessgreaterl): Ditto.
(isunordered): Ditto.
(isunorderedf): Ditto.
(isunorderedl): Ditto.
(iseqsig): Ditto.
(iseqsigf): Ditto.
(iseqsigl): Ditto.
(isnormal): Ditto.
(isnormalf): Ditto.
(isnormall): Ditto.
(isinf_sign): Ditto.
(isinf_signf): Ditto.
(isinf_signl): Ditto.
* gm2-libs/Builtins.mod (isgreater): New procedure function.
(isgreaterf): Ditto.
(isgreaterl): Ditto.
(isgreaterequal): Ditto.
(isgreaterequalf): Ditto.
(isgreaterequall): Ditto.
(isless): Ditto.
(islessf): Ditto.
(islessl): Ditto.
(islessequal): Ditto.
(islessequalf): Ditto.
(islessequall): Ditto.
(islessgreater): Ditto.
(islessgreaterf): Ditto.
(islessgreaterl): Ditto.
(isunordered): Ditto.
(isunorderedf): Ditto.
(isunorderedl): Ditto.
(iseqsig): Ditto.
(iseqsigf): Ditto.
(iseqsigl): Ditto.
(isnormal): Ditto.
(isnormalf): Ditto.
(isnormall): Ditto.
(isinf_sign): Ditto.
(isinf_signf): Ditto.
(isinf_signl): Ditto.

gcc/testsuite/ChangeLog:

PR modula2/114478
* gm2/builtins/run/pass/builtins-run-pass.exp: New test.
* gm2/builtins/run/pass/testcomparisons.mod: New test.
* gm2/builtins/run/pass/testisnormal.mod: New test.
* gm2/pimlib/run/pass/testchar.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-gcc/m2builtins.cc   | 147 +++
 gcc/m2/gm2-libs/Builtins.def   |  40 -
 gcc/m2/gm2-libs/Builtins.mod   | 161 +++--
 .../gm2/builtins/run/pass/builtins-run-pass.exp|  36 +
 .../gm2/builtins/run/pass/testcomparisons.mod  |  77 ++
 .../gm2/builtins/run/pass/testisnormal.mod |  49 +++
 gcc/testsuite/gm2/pimlib/run/pass/testchar.mod |  71 +
 7 files changed, 539 insertions(+), 42 deletions(-)

diff --git a/gcc/m2/gm2-gcc/m2builtins.cc b/gcc/m2/gm2-gcc/m2builtins.cc
index e4fc6a50c1c..cfb4751e15a 100644
--- a/gcc/m2/gm2-gcc/m2builtins.cc
+++ b/gcc/m2/gm2-gcc/m2builtins.cc
@@ -393,6 +393,13 @@ struct builtin_type_info
   tree (*functionHandler) (location_t, tree);
 };
 
+struct GTY(()) builtin_macro_definition
+{
+  const char *name;
+  tree function_node;
+  tree return_node;
+};
+
 static GTY (()) tree sizetype_endlink;
 static GTY (()) tree unsigned_endlink;
 static GTY (()) tree endlink;
@@ -418,6 +425,7 @@ static GTY (()) tree long_doubleptr_type_node;
 static GTY (()) tree doubleptr_type_node;
 static GTY (()) tree floatptr_type_node;
 static GTY (()) tree builtin_ftype_int_var;
+static GTY (()) vec *builtin_macros;
 
 /* Prototypes for locally defined functions.  */
 static tree DoBuiltinAlloca (location_t location, tree n);
@@ -916,21 +924,45 @@ m2builtins_BuiltinExists (char *name)
 if (strcmp (name, fe->name) == 0)
   return true;
   // return target_support_exists (fe);
-
+  int length = 

[gcc r12-10294] tree-optimization/110838 - less aggressively fold out-of-bound shifts

2024-03-26 Thread Andre Simoes Dias Vieira via Gcc-cvs
https://gcc.gnu.org/g:d0eed43ff39a0bad4a02f8af7a4795e06aea6f80

commit r12-10294-gd0eed43ff39a0bad4a02f8af7a4795e06aea6f80
Author: Richard Biener 
Date:   Fri Aug 4 11:24:49 2023 +0200

tree-optimization/110838 - less aggressively fold out-of-bound shifts

The following adjusts the shift simplification patterns to avoid
touching out-of-bound shift value arithmetic right shifts of
possibly negative values.  While simplifying those to zero isn't
wrong it's violating the principle of least surprise.

PR tree-optimization/110838
* match.pd (([rl]shift @0 out-of-bounds) -> zero): Restrict
the arithmetic right-shift case to non-negative operands.

(cherry picked from commit 04aa0edcace22a7815cfc57575f1f7b1f166ac10)

Diff:
---
 gcc/match.pd | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index 843b939fc34..c5a4426e76b 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -909,6 +909,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (simplify
   (shift @0 uniform_integer_cst_p@1)
   (if ((GIMPLE || !sanitize_flags_p (SANITIZE_SHIFT_EXPONENT))
+   /* Leave arithmetic right shifts of possibly negative values alone.  */
+   && (TYPE_UNSIGNED (type)
+   || shift == LSHIFT_EXPR
+  || tree_expr_nonnegative_p (@0))
/* Use a signed compare to leave negative shift counts alone.  */
&& wi::ges_p (wi::to_wide (uniform_integer_cst_p (@1)),
 element_precision (type)))


[gcc r12-10293] tree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C

2024-03-26 Thread Andre Simoes Dias Vieira via Gcc-cvs
https://gcc.gnu.org/g:1ddd9f9e53bd649d3d236f7941106d8cc46e7358

commit r12-10293-g1ddd9f9e53bd649d3d236f7941106d8cc46e7358
Author: Richard Biener 
Date:   Thu Jul 27 13:08:32 2023 +0200

tree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C

The following fixes the lack of simplification of a vector shift
by an out-of-bounds shift value.  For scalars this is done both
by CCP and VRP but vectors are not handled there.  This results
in PR91838 differences in outcome dependent on whether a vector
shift ISA is available and thus vector lowering does or does not
expose scalar shifts here.

The following adds a match.pd pattern to catch uniform out-of-bound
shifts, simplifying them to zero when not sanitizing shift amounts.

PR tree-optimization/91838
* gimple-match-head.cc: Include attribs.h and asan.h.
* generic-match-head.cc: Likewise.
* match.pd (([rl]shift @0 out-of-bounds) -> zero): New pattern.

(cherry picked from commit d1c072a1c3411a6fe29900750b38210af8451eeb)

Diff:
---
 gcc/generic-match-head.cc |  2 ++
 gcc/gimple-match-head.cc  |  2 ++
 gcc/match.pd  | 10 ++
 3 files changed, 14 insertions(+)

diff --git a/gcc/generic-match-head.cc b/gcc/generic-match-head.cc
index 749587eae5e..b6ba81c9c29 100644
--- a/gcc/generic-match-head.cc
+++ b/gcc/generic-match-head.cc
@@ -39,6 +39,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "dbgcnt.h"
 #include "tm.h"
 #include "tree-pass.h"
+#include "attribs.h"
+#include "asan.h"
 
 /* Routine to determine if the types T1 and T2 are effectively
the same for GENERIC.  If T1 or T2 is not a type, the test
diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc
index 1c74d38088f..2fd27fcbacc 100644
--- a/gcc/gimple-match-head.cc
+++ b/gcc/gimple-match-head.cc
@@ -45,6 +45,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "dbgcnt.h"
 #include "tm.h"
 #include "gimple-range.h"
+#include "attribs.h"
+#include "asan.h"
 
 /* Forward declarations of the private auto-generated matchers.
They expect valueized operands in canonical order and do not
diff --git a/gcc/match.pd b/gcc/match.pd
index a9aae484b2b..843b939fc34 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -904,6 +904,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& tree_nop_conversion_p (type, TREE_TYPE (@1)))
(lshift @0 @2)))
 
+/* Shifts by precision or greater result in zero.  */
+(for shift (lshift rshift)
+ (simplify
+  (shift @0 uniform_integer_cst_p@1)
+  (if ((GIMPLE || !sanitize_flags_p (SANITIZE_SHIFT_EXPONENT))
+   /* Use a signed compare to leave negative shift counts alone.  */
+   && wi::ges_p (wi::to_wide (uniform_integer_cst_p (@1)),
+element_precision (type)))
+   { build_zero_cst (type); })))
+
 /* Fold (1 << (C - x)) where C = precision(type) - 1
into ((1 << C) >> x). */
 (simplify


[gcc r13-8499] tree-optimization/110838 - less aggressively fold out-of-bound shifts

2024-03-26 Thread Andre Simoes Dias Vieira via Gcc-cvs
https://gcc.gnu.org/g:b170ab1d051dc97b2e5c03984dbe406939364adc

commit r13-8499-gb170ab1d051dc97b2e5c03984dbe406939364adc
Author: Richard Biener 
Date:   Fri Aug 4 11:24:49 2023 +0200

tree-optimization/110838 - less aggressively fold out-of-bound shifts

The following adjusts the shift simplification patterns to avoid
touching out-of-bound shift value arithmetic right shifts of
possibly negative values.  While simplifying those to zero isn't
wrong it's violating the principle of least surprise.

PR tree-optimization/110838
* match.pd (([rl]shift @0 out-of-bounds) -> zero): Restrict
the arithmetic right-shift case to non-negative operands.

(cherry picked from commit 04aa0edcace22a7815cfc57575f1f7b1f166ac10)

Diff:
---
 gcc/match.pd | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index 6812853df67..47e48fa2ca5 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1002,6 +1002,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (simplify
   (shift @0 uniform_integer_cst_p@1)
   (if ((GIMPLE || !sanitize_flags_p (SANITIZE_SHIFT_EXPONENT))
+   /* Leave arithmetic right shifts of possibly negative values alone.  */
+   && (TYPE_UNSIGNED (type)
+   || shift == LSHIFT_EXPR
+  || tree_expr_nonnegative_p (@0))
/* Use a signed compare to leave negative shift counts alone.  */
&& wi::ges_p (wi::to_wide (uniform_integer_cst_p (@1)),
 element_precision (type)))


[gcc r13-8498] tree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C

2024-03-26 Thread Andre Simoes Dias Vieira via Gcc-cvs
https://gcc.gnu.org/g:c6e171ff827f8ff1bd160babac0dd24933972664

commit r13-8498-gc6e171ff827f8ff1bd160babac0dd24933972664
Author: Richard Biener 
Date:   Thu Jul 27 13:08:32 2023 +0200

tree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C

The following fixes the lack of simplification of a vector shift
by an out-of-bounds shift value.  For scalars this is done both
by CCP and VRP but vectors are not handled there.  This results
in PR91838 differences in outcome dependent on whether a vector
shift ISA is available and thus vector lowering does or does not
expose scalar shifts here.

The following adds a match.pd pattern to catch uniform out-of-bound
shifts, simplifying them to zero when not sanitizing shift amounts.

PR tree-optimization/91838
* gimple-match-head.cc: Include attribs.h and asan.h.
* generic-match-head.cc: Likewise.
* match.pd (([rl]shift @0 out-of-bounds) -> zero): New pattern.

(cherry picked from commit d1c072a1c3411a6fe29900750b38210af8451eeb)

Diff:
---
 gcc/generic-match-head.cc |  2 ++
 gcc/gimple-match-head.cc  |  2 ++
 gcc/match.pd  | 10 ++
 3 files changed, 14 insertions(+)

diff --git a/gcc/generic-match-head.cc b/gcc/generic-match-head.cc
index f011204c5be..36f1832a05d 100644
--- a/gcc/generic-match-head.cc
+++ b/gcc/generic-match-head.cc
@@ -41,6 +41,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-eh.h"
 #include "langhooks.h"
 #include "tree-pass.h"
+#include "attribs.h"
+#include "asan.h"
 
 /* Routine to determine if the types T1 and T2 are effectively
the same for GENERIC.  If T1 or T2 is not a type, the test
diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc
index ec603f9d043..21843d7870b 100644
--- a/gcc/gimple-match-head.cc
+++ b/gcc/gimple-match-head.cc
@@ -47,6 +47,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "gimple-range.h"
 #include "langhooks.h"
+#include "attribs.h"
+#include "asan.h"
 
 /* Forward declarations of the private auto-generated matchers.
They expect valueized operands in canonical order and do not
diff --git a/gcc/match.pd b/gcc/match.pd
index 908959de3e7..6812853df67 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -997,6 +997,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& tree_nop_conversion_p (type, TREE_TYPE (@1)))
(lshift @0 @2)))
 
+/* Shifts by precision or greater result in zero.  */
+(for shift (lshift rshift)
+ (simplify
+  (shift @0 uniform_integer_cst_p@1)
+  (if ((GIMPLE || !sanitize_flags_p (SANITIZE_SHIFT_EXPONENT))
+   /* Use a signed compare to leave negative shift counts alone.  */
+   && wi::ges_p (wi::to_wide (uniform_integer_cst_p (@1)),
+element_precision (type)))
+   { build_zero_cst (type); })))
+
 /* Shifts by constants distribute over several binary operations,
hence (X << C) + (Y << C) can be simplified to (X + Y) << C.  */
 (for op (plus minus)


[gcc r14-9674] c++: add fixed test [PR100557]

2024-03-26 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:c0e199e4dbe652cd16d7248f0bfe166540f5d95b

commit r14-9674-gc0e199e4dbe652cd16d7248f0bfe166540f5d95b
Author: Marek Polacek 
Date:   Tue Mar 26 10:39:48 2024 -0400

c++: add fixed test [PR100557]

We used to hit the "Error reporting routines re-entered." ICE here but
it was fixed by Patrick's r14-3809.

PR c++/100557

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-pr100557.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/cpp2a/concepts-pr100557.C | 21 +
 1 file changed, 21 insertions(+)

diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-pr100557.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-pr100557.C
new file mode 100644
index 000..8dcd0eaca51
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-pr100557.C
@@ -0,0 +1,21 @@
+// PR c++/100557
+// { dg-do compile { target c++20 } }
+
+template  _Tp declval();
+
+struct print_tag_;
+
+bool tag_invoke(print_tag_, auto);
+bool tag_invoke(print_tag_, auto obj) requires requires { *obj; };
+
+template 
+auto try_tag_invoke() noexcept(tag_invoke(declval, declval()...)) 
// { dg-error "no matching function for call" }
+-> decltype(tag_invoke(CPO(), declval()...));
+
+struct print_tag_ {
+  void operator()(auto... args) noexcept(noexcept( try_tag_invoke()));
+} print;
+
+void foo() {
+  print(0);
+}


[gcc r14-9673] c++/modules testsuite: fix a couple of dg-module-do directives

2024-03-26 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:2f47ca046eecf8f2fcae23df3ccee44d943ef512

commit r14-9673-g2f47ca046eecf8f2fcae23df3ccee44d943ef512
Author: Patrick Palka 
Date:   Tue Mar 26 10:21:53 2024 -0400

c++/modules testsuite: fix a couple of dg-module-do directives

gcc/testsuite/ChangeLog:

* g++.dg/modules/decltype-1_a.C: Add missing } to dg-module-do
directive.
* g++.dg/modules/lambda-5_a.C: Likewise.

Diff:
---
 gcc/testsuite/g++.dg/modules/decltype-1_a.C | 2 +-
 gcc/testsuite/g++.dg/modules/lambda-5_a.C   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/modules/decltype-1_a.C 
b/gcc/testsuite/g++.dg/modules/decltype-1_a.C
index ca66e8b598a..e4202a26de4 100644
--- a/gcc/testsuite/g++.dg/modules/decltype-1_a.C
+++ b/gcc/testsuite/g++.dg/modules/decltype-1_a.C
@@ -1,5 +1,5 @@
 // PR c++/105322
-// { dg-module-do link
+// { dg-module-do link }
 // { dg-additional-options -fmodules-ts }
 // { dg-module-cmi pr105322.Decltype }
 
diff --git a/gcc/testsuite/g++.dg/modules/lambda-5_a.C 
b/gcc/testsuite/g++.dg/modules/lambda-5_a.C
index 6b589d4965c..37d0e77b1e1 100644
--- a/gcc/testsuite/g++.dg/modules/lambda-5_a.C
+++ b/gcc/testsuite/g++.dg/modules/lambda-5_a.C
@@ -1,5 +1,5 @@
 // PR c++/105322
-// { dg-module-do link
+// { dg-module-do link }
 // { dg-additional-options -fmodules-ts }
 // { dg-module-cmi pr105322.Lambda }


[gcc r14-9672] aarch64: Fix SCHEDULER_IDENT for Cortex-A510 and Cortex-A520

2024-03-26 Thread Richard Ball via Gcc-cvs
https://gcc.gnu.org/g:cab53aae43cf94171b01320c08302e47a5daa391

commit r14-9672-gcab53aae43cf94171b01320c08302e47a5daa391
Author: Richard Ball 
Date:   Tue Mar 26 13:54:31 2024 +

aarch64: Fix SCHEDULER_IDENT for Cortex-A510 and Cortex-A520

The SCHEDULER_IDENT for these two CPUs
was incorrectly set to cortexa55.
This can cause sub-optimal asm
 to be generated.

gcc/ChangeLog:
PR target/114272
* config/aarch64/aarch64-cores.def (AARCH64_CORE):
Change SCHEDULER_IDENT from cortexa55 to cortexa53
for Cortex-A510 and Cortex-A520.

Diff:
---
 gcc/config/aarch64/aarch64-cores.def | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-cores.def 
b/gcc/config/aarch64/aarch64-cores.def
index 7ebefcf543b..f69fc212d56 100644
--- a/gcc/config/aarch64/aarch64-cores.def
+++ b/gcc/config/aarch64/aarch64-cores.def
@@ -169,9 +169,9 @@ AARCH64_CORE("cortex-r82", cortexr82, cortexa53, V8R, (), 
cortexa53, 0x41, 0xd15
 /* Armv9.0-A Architecture Processors.  */
 
 /* Arm ('A') cores. */
-AARCH64_CORE("cortex-a510",  cortexa510, cortexa55, V9A,  (SVE2_BITPERM, 
MEMTAG, I8MM, BF16), cortexa53, 0x41, 0xd46, -1)
+AARCH64_CORE("cortex-a510",  cortexa510, cortexa53, V9A,  (SVE2_BITPERM, 
MEMTAG, I8MM, BF16), cortexa53, 0x41, 0xd46, -1)
 
-AARCH64_CORE("cortex-a520",  cortexa520, cortexa55, V9_2A,  (SVE2_BITPERM, 
MEMTAG), cortexa53, 0x41, 0xd80, -1)
+AARCH64_CORE("cortex-a520",  cortexa520, cortexa53, V9_2A,  (SVE2_BITPERM, 
MEMTAG), cortexa53, 0x41, 0xd80, -1)
 
 AARCH64_CORE("cortex-a710",  cortexa710, cortexa57, V9A,  (SVE2_BITPERM, 
MEMTAG, I8MM, BF16), neoversen2, 0x41, 0xd47, -1)


[gcc r14-9671] libstdc++: Replace stacktrace effective target with feature test

2024-03-26 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:217e778a31d68815b029f5110825cd36caefd908

commit r14-9671-g217e778a31d68815b029f5110825cd36caefd908
Author: Jonathan Wakely 
Date:   Fri Mar 22 22:26:10 2024 +

libstdc++: Replace stacktrace effective target with feature test

Rmove the dejagnu code for checking whether std::stacktrace is supported
and just use the new dg-require-cpp-feature-test directive to check for
__cpp_lib_stacktrace instead.

libstdc++-v3/ChangeLog:

* testsuite/19_diagnostics/stacktrace/current.cc: Check for
__cpp_lib_stacktrace instead of check for stacktrace ET.
* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/hash.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/output.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/synopsis.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/version.cc: Likewise.
* testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc:
Likewise.
* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
Remove.

Diff:
---
 libstdc++-v3/testsuite/19_diagnostics/stacktrace/current.cc   | 2 +-
 libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc | 2 +-
 libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc  | 2 +-
 libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc| 2 +-
 libstdc++-v3/testsuite/19_diagnostics/stacktrace/stacktrace.cc| 2 +-
 libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc  | 2 +-
 libstdc++-v3/testsuite/19_diagnostics/stacktrace/version.cc   | 2 +-
 .../testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc | 2 +-
 libstdc++-v3/testsuite/lib/libstdc++.exp  | 8 
 9 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/current.cc 
b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/current.cc
index a27836d27af..b1af5f74fb2 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/current.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/current.cc
@@ -1,6 +1,6 @@
 // { dg-options "-lstdc++exp" }
 // { dg-do run { target c++23 } }
-// { dg-require-effective-target stacktrace }
+// { dg-require-cpp-feature-test __cpp_lib_stacktrace }
 
 #include 
 #include 
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc 
b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc
index ab016d56400..bb348ebef8f 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc
@@ -1,6 +1,6 @@
 // { dg-options "-lstdc++exp" }
 // { dg-do run { target c++23 } }
-// { dg-require-effective-target stacktrace }
+// { dg-require-cpp-feature-test __cpp_lib_stacktrace }
 
 #include 
 #include "testsuite_hooks.h"
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc 
b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc
index 21705098ff0..2176596ae5c 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc
@@ -1,6 +1,6 @@
 // { dg-options "-lstdc++exp" }
 // { dg-do run { target c++23 } }
-// { dg-require-effective-target stacktrace }
+// { dg-require-cpp-feature-test __cpp_lib_stacktrace }
 
 #include 
 #include 
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc 
b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc
index 67f1e0cebaf..e27aea1f508 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/output.cc
@@ -1,6 +1,6 @@
 // { dg-options "-lstdc++exp" }
 // { dg-do run { target c++23 } }
-// { dg-require-effective-target stacktrace }
+// { dg-require-cpp-feature-test __cpp_lib_stacktrace }
 // { dg-add-options no_pch }
 
 #include 
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/stacktrace.cc 
b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/stacktrace.cc
index 5dfa76951df..070c4157471 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/stacktrace.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/stacktrace.cc
@@ -1,6 +1,6 @@
 // { dg-options "-lstdc++exp" }
 // { dg-do run { target c++23 } }
-// { dg-require-effective-target stacktrace }
+// { dg-require-cpp-feature-test __cpp_lib_stacktrace }
 
 #include 
 #include "testsuite_allocator.h"
diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc 
b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc
index 9e775b86ac9..b99d382ec26 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/synopsis.cc
@@ -1,5 +1,5 @@
 // { dg-do compile { target c++23 } }
-// 

[gcc r14-9670] libstdc++: Add dg-require-cpp-feature-test to test feature test macros

2024-03-26 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:4a3a1b6b75f921d35bbfef26619e7b5cece3fcf0

commit r14-9670-g4a3a1b6b75f921d35bbfef26619e7b5cece3fcf0
Author: Jonathan Wakely 
Date:   Fri Mar 22 22:01:50 2024 +

libstdc++: Add dg-require-cpp-feature-test to test feature test macros

This adds a new dejagnu directive which can be used to make a test
depend on a feature test macro such as __cpp_lib_text_encoding. This is
mroe flexible than writing a new dg-require-xxx for each feature.

libstdc++-v3/ChangeLog:

* testsuite/lib/dg-options.exp (dg-require-cpp-feature-test):
New proc.
* testsuite/lib/libstdc++.exp (check_v3_target_cpp_feature_test):
New proc.
* testsuite/std/text_encoding/cons.cc: Use new directive to skip
the test if the __cpp_lib_text_encoding feature test macro is
not defined.
* testsuite/std/text_encoding/requirements.cc: Likewise.

Diff:
---
 libstdc++-v3/testsuite/lib/dg-options.exp|  9 +
 libstdc++-v3/testsuite/lib/libstdc++.exp | 15 +++
 libstdc++-v3/testsuite/std/text_encoding/cons.cc |  1 +
 libstdc++-v3/testsuite/std/text_encoding/requirements.cc |  1 +
 4 files changed, 26 insertions(+)

diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp 
b/libstdc++-v3/testsuite/lib/dg-options.exp
index 00ca678a53a..802bfc0b492 100644
--- a/libstdc++-v3/testsuite/lib/dg-options.exp
+++ b/libstdc++-v3/testsuite/lib/dg-options.exp
@@ -277,6 +277,15 @@ proc dg-require-target-fs-lwt { args } {
 return
 }
 
+proc dg-require-cpp-feature-test { n args } {
+if { ![ check_v3_target_cpp_feature_test $args ] } {
+   upvar dg-do-what dg-do-what
+   set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+   return
+}
+return
+}
+
 proc add_options_for_no_pch { flags } {
 # Remove any inclusion of bits/stdc++.h from the options.
 regsub -all -- "-include bits/stdc...h" $flags "" flags
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 7466fb51c58..2b31c950826 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1134,6 +1134,21 @@ proc v3_check_preprocessor_condition { name cond { inc 
"" } } {
 return [v3_try_preprocess name $code $flags]
 }
 
+# Return 1 if libstdc++ defines macro for the current target, 0 otherwise.
+proc check_v3_target_cpp_feature_test { cond } {
+global cxxflags
+set cxxflags_saved $cxxflags
+# Use the latest standard, so that all feature test macros are defined.
+# We need to do it here, because this check happens before v3-dg-runtest
+# runs its loop to test multiple times with different -std options.
+# This should be updated when a new -std is added.
+set cxxflags "$cxxflags -std=gnu++26"
+set inc "#include "
+set result [v3_check_preprocessor_condition cpp_feature_test "$cond" $inc]
+set cxxflags $cxxflags_saved
+return $result
+}
+
 # Return 1 if Debug Mode is active, 0 otherwise.
 proc check_v3_target_debug_mode { } {
 global cxxflags
diff --git a/libstdc++-v3/testsuite/std/text_encoding/cons.cc 
b/libstdc++-v3/testsuite/std/text_encoding/cons.cc
index 8fcc2ec8c3b..4196e32ea8b 100644
--- a/libstdc++-v3/testsuite/std/text_encoding/cons.cc
+++ b/libstdc++-v3/testsuite/std/text_encoding/cons.cc
@@ -1,4 +1,5 @@
 // { dg-do run { target c++26 } }
+// { dg-require-cpp-feature-test "__cpp_lib_text_encoding" }
 
 #include 
 #include 
diff --git a/libstdc++-v3/testsuite/std/text_encoding/requirements.cc 
b/libstdc++-v3/testsuite/std/text_encoding/requirements.cc
index 6cd71b68225..3889b250688 100644
--- a/libstdc++-v3/testsuite/std/text_encoding/requirements.cc
+++ b/libstdc++-v3/testsuite/std/text_encoding/requirements.cc
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++26 } }
+// { dg-require-cpp-feature-test __cpp_lib_text_encoding }
 // { dg-add-options no_pch }
 
 #include 


[gcc r14-9669] testsuite: Add -Wno-psabi to pr113126.c test

2024-03-26 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:4549b0f67d52b4f042ab89a036249545c3938b45

commit r14-9669-g4549b0f67d52b4f042ab89a036249545c3938b45
Author: Jakub Jelinek 
Date:   Tue Mar 26 11:25:15 2024 +0100

testsuite: Add -Wno-psabi to pr113126.c test

I've missed
FAIL: gcc.dg/torture/pr113126.c   -O0  (test for excess errors)
etc. regressions on i686-linux since January.  The problem is obvious
Excess errors:
.../gcc/testsuite/gcc.dg/torture/pr113126.c:11:1: warning: MMX vector 
return without MMX enabled changes the ABI [-Wpsabi]
and I've added -Wno-psabi to dg-additional-options to fix that up.

2024-03-26  Jakub Jelinek  

* gcc.dg/torture/pr113126.c: Add -Wno-psabi as 
dg-additional-options.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr113126.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr113126.c 
b/gcc/testsuite/gcc.dg/torture/pr113126.c
index 4aa38e0a255..ffe29799d13 100644
--- a/gcc/testsuite/gcc.dg/torture/pr113126.c
+++ b/gcc/testsuite/gcc.dg/torture/pr113126.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-psabi" } */
 
 typedef float __attribute__((__vector_size__ (8))) F;
 typedef double __attribute__((__vector_size__ (16))) G;


[gcc r14-9668] fold-const: Punt on MULT_EXPR in extract_muldiv MIN/MAX_EXPR case [PR111151]

2024-03-26 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:c4f2c84e8fa369856aee76679590eb613724bfb0

commit r14-9668-gc4f2c84e8fa369856aee76679590eb613724bfb0
Author: Jakub Jelinek 
Date:   Tue Mar 26 11:21:38 2024 +0100

fold-const: Punt on MULT_EXPR in extract_muldiv MIN/MAX_EXPR case [PR51]

As I've tried to explain in the comments, the extract_muldiv_1
MIN/MAX_EXPR optimization is wrong for code == MULT_EXPR.
If the multiplication is done in unsigned type or in signed
type with -fwrapv, it is fairly obvious that max (a, b) * c
in many cases isn't equivalent to max (a * c, b * c) (or min if c is
negative) due to overflows, but even for signed with undefined overflow,
the optimization could turn something without UB in it (where
say a * c invokes UB, but max (or min) picks the other operand where
b * c doesn't).
As for division/modulo, I think it is in most cases safe, except if
the problematic INT_MIN / -1 case could be triggered, but we can
just punt for MAX_EXPR because for MIN_EXPR if one operand is INT_MIN,
we'd pick that operand already.  It is just for completeness, match.pd
already has an optimization which turns x / -1 into -x, so the division
by zero is mostly theoretical.  That is also why in the testcase the
i case isn't actually miscompiled without the patch, while the c and f
cases are.

2024-03-26  Jakub Jelinek  

PR middle-end/51
* fold-const.cc (extract_muldiv_1) : Punt for
MULT_EXPR altogether, or for MAX_EXPR if c is -1.

* gcc.c-torture/execute/pr51.c: New test.

Diff:
---
 gcc/fold-const.cc  | 21 +
 gcc/testsuite/gcc.c-torture/execute/pr51.c | 21 +
 2 files changed, 42 insertions(+)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 299c22bf391..8960e5289c0 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -7104,6 +7104,27 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, 
tree wide_type,
   if (TYPE_UNSIGNED (ctype) != TYPE_UNSIGNED (type))
break;
 
+  /* Punt for multiplication altogether.
+MAX (1U + INT_MAX, 1U) * 2U is not equivalent to
+MAX ((1U + INT_MAX) * 2U, 1U * 2U), the former is
+0U, the latter is 2U.
+MAX (INT_MIN / 2, 0) * -2 is not equivalent to
+MIN (INT_MIN / 2 * -2, 0 * -2), the former is
+well defined 0, the latter invokes UB.
+MAX (INT_MIN / 2, 5) * 5 is not equivalent to
+MAX (INT_MIN / 2 * 5, 5 * 5), the former is
+well defined 25, the latter invokes UB.  */
+  if (code == MULT_EXPR)
+   break;
+  /* For division/modulo, punt on c being -1 for MAX, as
+MAX (INT_MIN, 0) / -1 is not equivalent to
+MIN (INT_MIN / -1, 0 / -1), the former is well defined
+0, the latter invokes UB (or for -fwrapv is INT_MIN).
+MIN (INT_MIN, 0) / -1 already invokes UB, so the
+transformation won't make it worse.  */
+  else if (tcode == MAX_EXPR && integer_minus_onep (c))
+   break;
+
   /* MIN (a, b) / 5 -> MIN (a / 5, b / 5)  */
   sub_strict_overflow_p = false;
   if ((t1 = extract_muldiv (op0, c, code, wide_type,
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr51.c 
b/gcc/testsuite/gcc.c-torture/execute/pr51.c
new file mode 100644
index 000..89255d28054
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr51.c
@@ -0,0 +1,21 @@
+/* PR middle-end/51 */
+
+int
+main ()
+{
+  unsigned a = (1U + __INT_MAX__) / 2U;
+  unsigned b = 1U;
+  unsigned c = (a * 2U > b * 2U ? a * 2U : b * 2U) * 2U;
+  if (c != 0U)
+__builtin_abort ();
+  int d = (-__INT_MAX__ - 1) / 2;
+  int e = 10;
+  int f = (d * 2 > e * 5 ? d * 2 : e * 5) * 6;
+  if (f != 120)
+__builtin_abort ();
+  int g = (-__INT_MAX__ - 1) / 2;
+  int h = 0;
+  int i = (g * 2 > h * 5 ? g * 2 : h * 5) / -1;
+  if (i != 0)
+__builtin_abort ();
+}


[gcc r14-9667] tsan: Don't instrument non-generic AS accesses [PR111736]

2024-03-26 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:471967ab8b4c49338ba77defbe24b06cc51c0093

commit r14-9667-g471967ab8b4c49338ba77defbe24b06cc51c0093
Author: Jakub Jelinek 
Date:   Tue Mar 26 11:06:15 2024 +0100

tsan: Don't instrument non-generic AS accesses [PR111736]

Similar to the asan and ubsan changes, we shouldn't instrument non-generic
address space accesses with tsan, because we just have library functions
which take address of the objects as generic address space pointers, so they
can't handle anything else.

2024-03-26  Jakub Jelinek  

PR sanitizer/111736
* tsan.cc (instrument_expr): Punt on non-generic address space
accesses.

* gcc.dg/tsan/pr111736.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/tsan/pr111736.c | 17 +
 gcc/tsan.cc  |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/tsan/pr111736.c 
b/gcc/testsuite/gcc.dg/tsan/pr111736.c
new file mode 100644
index 000..34ab88b3d4f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tsan/pr111736.c
@@ -0,0 +1,17 @@
+/* PR sanitizer/111736 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-fsanitize=thread -fdump-tree-optimized -ffat-lto-objects" } 
*/
+/* { dg-final { scan-tree-dump-not "__tsan_read" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "__tsan_write" "optimized" } } */
+
+#ifdef __x86_64__
+#define SEG __seg_fs
+#else
+#define SEG __seg_gs
+#endif
+
+void
+foo (int SEG *p, int SEG *q)
+{
+  *q = *p;
+}
diff --git a/gcc/tsan.cc b/gcc/tsan.cc
index e73e1d37178..590e97d397b 100644
--- a/gcc/tsan.cc
+++ b/gcc/tsan.cc
@@ -139,6 +139,9 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool 
is_write)
   if (TREE_READONLY (base) || (VAR_P (base) && DECL_HARD_REGISTER (base)))
 return false;
 
+  if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (base
+return false;
+
   stmt = gsi_stmt (gsi);
   loc = gimple_location (stmt);
   rhs = is_vptr_store (stmt, expr, is_write);


[gcc r14-9666] tree-optimization/114471 - ICE with mismatching vector types

2024-03-26 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:f4e92d62dccb96ade753f3a8f49be1b5f61c31f1

commit r14-9666-gf4e92d62dccb96ade753f3a8f49be1b5f61c31f1
Author: Richard Biener 
Date:   Tue Mar 26 09:11:00 2024 +0100

tree-optimization/114471 - ICE with mismatching vector types

The following fixes too lax verification of vector type compatibility
in vectorizable_operation.  When we only have a single vector size then
comparing the number of elements is enough but with SLP we mix those
and thus for operations like BIT_AND_EXPR we need to verify compatible
element types as well.  Allow sign changes for ABSU_EXPR though.

PR tree-optimization/114471
* tree-vect-stmts.cc (vectorizable_operation): Verify operand
types are compatible with the result type.

* gcc.dg/vect/pr114471.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr114471.c | 13 +
 gcc/tree-vect-stmts.cc   | 11 ---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr114471.c 
b/gcc/testsuite/gcc.dg/vect/pr114471.c
new file mode 100644
index 000..218c953e45e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114471.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+float f1, f0, fa[2];
+short sa[2];
+void quantize(short s0)
+{
+  _Bool ta[2] = {(fa[0] < 0), (fa[1] < 0)};
+  _Bool t = ((s0 > 0) & ta[0]);
+  short x1 = s0 + t;
+  _Bool t1 = ((x1 > 0) & ta[1]);
+  sa[0] = x1;
+  sa[1] = s0 + t1;
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 5a4eb136c6d..f8d8636b139 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -6667,7 +6667,8 @@ vectorizable_operation (vec_info *vinfo,
 
   nunits_out = TYPE_VECTOR_SUBPARTS (vectype_out);
   nunits_in = TYPE_VECTOR_SUBPARTS (vectype);
-  if (maybe_ne (nunits_out, nunits_in))
+  if (maybe_ne (nunits_out, nunits_in)
+  || !tree_nop_conversion_p (TREE_TYPE (vectype_out), TREE_TYPE (vectype)))
 return false;
 
   tree vectype2 = NULL_TREE, vectype3 = NULL_TREE;
@@ -6685,7 +6686,9 @@ vectorizable_operation (vec_info *vinfo,
   is_invariant &= (dt[1] == vect_external_def
   || dt[1] == vect_constant_def);
   if (vectype2
- && maybe_ne (nunits_out, TYPE_VECTOR_SUBPARTS (vectype2)))
+ && (maybe_ne (nunits_out, TYPE_VECTOR_SUBPARTS (vectype2))
+ || !tree_nop_conversion_p (TREE_TYPE (vectype_out),
+TREE_TYPE (vectype2
return false;
 }
   if (op_type == ternary_op)
@@ -6701,7 +6704,9 @@ vectorizable_operation (vec_info *vinfo,
   is_invariant &= (dt[2] == vect_external_def
   || dt[2] == vect_constant_def);
   if (vectype3
- && maybe_ne (nunits_out, TYPE_VECTOR_SUBPARTS (vectype3)))
+ && (maybe_ne (nunits_out, TYPE_VECTOR_SUBPARTS (vectype3))
+ || !tree_nop_conversion_p (TREE_TYPE (vectype_out),
+TREE_TYPE (vectype3
return false;
 }


[gcc r14-9665] tree-optimization/114464 - verify types in recurrence vectorization

2024-03-26 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:226a220d0056396e825e12435cc0da52cbd5ac56

commit r14-9665-g226a220d0056396e825e12435cc0da52cbd5ac56
Author: Richard Biener 
Date:   Tue Mar 26 09:39:30 2024 +0100

tree-optimization/114464 - verify types in recurrence vectorization

The following adds missing verification of vector type compatibility
to recurrence vectorization.

PR tree-optimization/114464
* tree-vect-loop.cc (vectorizable_recurr): Verify the latch
vector type is compatible with what we chose for the recurrence.

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

Diff:
---
 gcc/testsuite/g++.dg/vect/pr114464.cc | 11 +++
 gcc/tree-vect-loop.cc | 22 ++
 2 files changed, 33 insertions(+)

diff --git a/gcc/testsuite/g++.dg/vect/pr114464.cc 
b/gcc/testsuite/g++.dg/vect/pr114464.cc
new file mode 100644
index 000..0d872aae9d4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/pr114464.cc
@@ -0,0 +1,11 @@
+// { dg-do compile }
+
+void h(unsigned char *scratch, bool carry)
+{
+  for (int i = 0; i < 16; i++) {
+bool b = scratch[i] <<= 1;
+if (carry)
+  scratch[i] |= 1;
+carry = b;
+  }
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 2921a9e6aa1..f33629e9b04 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -9197,6 +9197,28 @@ vectorizable_recurr (loop_vec_info loop_vinfo, 
stmt_vec_info stmt_info,
return false;
  }
}
+
+  /* Verify we have set up compatible types.  */
+  edge le = loop_latch_edge (LOOP_VINFO_LOOP (loop_vinfo));
+  tree latch_vectype = NULL_TREE;
+  if (slp_node)
+   {
+ slp_tree latch_def = SLP_TREE_CHILDREN (slp_node)[le->dest_idx];
+ latch_vectype = SLP_TREE_VECTYPE (latch_def);
+   }
+  else
+   {
+ tree latch_def = PHI_ARG_DEF_FROM_EDGE (phi, le);
+ if (TREE_CODE (latch_def) == SSA_NAME)
+   {
+ stmt_vec_info latch_def_info = loop_vinfo->lookup_def (latch_def);
+ latch_def_info = vect_stmt_to_vectorize (latch_def_info);
+ latch_vectype = STMT_VINFO_VECTYPE (latch_def_info);
+   }
+   }
+  if (!types_compatible_p (latch_vectype, vectype))
+   return false;
+
   /* The recurrence costs the initialization vector and one permute
 for each copy.  */
   unsigned prologue_cost = record_stmt_cost (cost_vec, 1, scalar_to_vec,


[gcc r14-9664] cfgloopmanip, i386: Fix comment typos

2024-03-26 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:94b91b2786531ed8e2d07a6ad1191b5dfa0141e5

commit r14-9664-g94b91b2786531ed8e2d07a6ad1191b5dfa0141e5
Author: Jakub Jelinek 
Date:   Tue Mar 26 10:05:23 2024 +0100

cfgloopmanip, i386: Fix comment typos

I've noticed a comment typo in x86-tune.def and cfgloopmanip.cc has the
same typo as well.

2024-03-26  Jakub Jelinek  

* cfgloopmanip.cc (update_loop_exit_probability_scale_dom_bbs):
Fix comment typo - multple -> multiple.
* config/i386/x86-tune.def (X86_TUNE_ACCUMULATE_OUTGOING_ARGS):
Likewise.

Diff:
---
 gcc/cfgloopmanip.cc  | 2 +-
 gcc/config/i386/x86-tune.def | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/cfgloopmanip.cc b/gcc/cfgloopmanip.cc
index 946cbe6085c..3707db2fdb3 100644
--- a/gcc/cfgloopmanip.cc
+++ b/gcc/cfgloopmanip.cc
@@ -669,7 +669,7 @@ update_loop_exit_probability_scale_dom_bbs (class loop 
*loop,
 + old_exit_count - exit_edge->count ();
 }
   else
-/* If there are multple blocks, just scale.  */
+/* If there are multiple blocks, just scale.  */
 scale_dominated_blocks_in_loop (loop, exit_edge->src,
exit_edge->src->count - exit_edge->count (),
exit_edge->src->count - old_exit_count);
diff --git a/gcc/config/i386/x86-tune.def b/gcc/config/i386/x86-tune.def
index ae2797b7cc2..710009712f6 100644
--- a/gcc/config/i386/x86-tune.def
+++ b/gcc/config/i386/x86-tune.def
@@ -157,7 +157,7 @@ DEF_TUNE (X86_TUNE_FUSE_ALU_AND_BRANCH, 
"fuse_alu_and_branch",
by push/pop instructions.
This increase code size by about 5% in 32bit mode, less so in 64bit mode
because parameters are passed in registers.  It is considerable
-   win for targets without stack engine that prevents multple push operations
+   win for targets without stack engine that prevents multiple push operations
to happen in parallel.  */
 
 DEF_TUNE (X86_TUNE_ACCUMULATE_OUTGOING_ARGS, "accumulate_outgoing_args",


[gcc r14-9663] c-family, c++: Handle EXCESS_PRECISION_EXPR in pretty printers [PR112724]

2024-03-26 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:10accfde57951db9f726e996f1b0be165df00f5c

commit r14-9663-g10accfde57951db9f726e996f1b0be165df00f5c
Author: Jakub Jelinek 
Date:   Tue Mar 26 10:03:27 2024 +0100

c-family, c++: Handle EXCESS_PRECISION_EXPR in pretty printers [PR112724]

I've noticed that the c-c++-common/gomp/depobj-3.c test FAILs on i686-linux:
PASS: c-c++-common/gomp/depobj-3.c  -std=c++17  at line 17 (test for 
warnings, line 15)
FAIL: c-c++-common/gomp/depobj-3.c  -std=c++17  at line 39 (test for 
warnings, line 37)
PASS: c-c++-common/gomp/depobj-3.c  -std=c++17  at line 43 (test for 
errors, line 41)
PASS: c-c++-common/gomp/depobj-3.c  -std=c++17  (test for warnings, line 45)
FAIL: c-c++-common/gomp/depobj-3.c  -std=c++17 (test for excess errors)
Excess errors:
/home/jakub/src/gcc/gcc/testsuite/c-c++-common/gomp/depobj-3.c:37:38: 
warning: the 'destroy' expression ''excess_precision_expr' not supported by 
dump_expr' should
+be the same as the 'depobj' argument 'obj' [-Wopenmp]
The following patch replaces that 'excess_precision_expr' not supported by 
dump_expr
with (float)(((long double)a) + (long double)5)
Still ugly and doesn't actually fix the FAIL (will deal with that
incrementally), but at least valid C/C++ and shows the excess precision
handling in action.

2024-03-26  Jakub Jelinek  

PR c++/112724
gcc/c-family/
* c-pretty-print.cc (pp_c_cast_expression,
c_pretty_printer::expression): Handle EXCESS_PRECISION_EXPR like
NOP_EXPR.
gcc/cp/
* error.cc (dump_expr): Handle EXCESS_PRECISION_EXPR like NOP_EXPR.

Diff:
---
 gcc/c-family/c-pretty-print.cc | 2 ++
 gcc/cp/error.cc| 1 +
 2 files changed, 3 insertions(+)

diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc
index 45045fb2242..da7934d783a 100644
--- a/gcc/c-family/c-pretty-print.cc
+++ b/gcc/c-family/c-pretty-print.cc
@@ -2327,6 +2327,7 @@ pp_c_cast_expression (c_pretty_printer *pp, tree e)
 case FIX_TRUNC_EXPR:
 CASE_CONVERT:
 case VIEW_CONVERT_EXPR:
+case EXCESS_PRECISION_EXPR:
   if (!location_wrapper_p (e))
pp_c_type_cast (pp, TREE_TYPE (e));
   pp_c_cast_expression (pp, TREE_OPERAND (e, 0));
@@ -2753,6 +2754,7 @@ c_pretty_printer::expression (tree e)
 case FIX_TRUNC_EXPR:
 CASE_CONVERT:
 case VIEW_CONVERT_EXPR:
+case EXCESS_PRECISION_EXPR:
   pp_c_cast_expression (this, e);
   break;
 
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index d3fcac70ea1..7074845154e 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -2662,6 +2662,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
 CASE_CONVERT:
 case IMPLICIT_CONV_EXPR:
 case VIEW_CONVERT_EXPR:
+case EXCESS_PRECISION_EXPR:
   {
tree op = TREE_OPERAND (t, 0);


[gcc r13-8497] tree-optimization/114027 - fix testcase

2024-03-26 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:66090b8f438daff7b529f9adae0d6d5be7aa2a1f

commit r13-8497-g66090b8f438daff7b529f9adae0d6d5be7aa2a1f
Author: Richard Biener 
Date:   Tue Mar 26 09:46:06 2024 +0100

tree-optimization/114027 - fix testcase

The following fixes out-of-bounds read in the testcase.

PR tree-optimization/114027
* gcc.dg/vect/pr114027.c: Fix iteration count.

(cherry picked from commit 4470611e20f3217ee81647b01fda65b6a62229aa)

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr114027.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr114027.c 
b/gcc/testsuite/gcc.dg/vect/pr114027.c
index ead9cdd982d..b3f3e30e15f 100644
--- a/gcc/testsuite/gcc.dg/vect/pr114027.c
+++ b/gcc/testsuite/gcc.dg/vect/pr114027.c
@@ -20,7 +20,7 @@ int f[] = { 1, 1, 1, 1, 1, 1, 1, 1,
 int
 main ()
 {
-  if (foo (f, 16) != 2)
+  if (foo (f, 8) != 2)
 __builtin_abort ();
   return 0;
 }


[gcc r14-9662] tree-optimization/114027 - fix testcase

2024-03-26 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:4470611e20f3217ee81647b01fda65b6a62229aa

commit r14-9662-g4470611e20f3217ee81647b01fda65b6a62229aa
Author: Richard Biener 
Date:   Tue Mar 26 09:46:06 2024 +0100

tree-optimization/114027 - fix testcase

The following fixes out-of-bounds read in the testcase.

PR tree-optimization/114027
* gcc.dg/vect/pr114027.c: Fix iteration count.

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr114027.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr114027.c 
b/gcc/testsuite/gcc.dg/vect/pr114027.c
index ead9cdd982d..b3f3e30e15f 100644
--- a/gcc/testsuite/gcc.dg/vect/pr114027.c
+++ b/gcc/testsuite/gcc.dg/vect/pr114027.c
@@ -20,7 +20,7 @@ int f[] = { 1, 1, 1, 1, 1, 1, 1, 1,
 int
 main ()
 {
-  if (foo (f, 16) != 2)
+  if (foo (f, 8) != 2)
 __builtin_abort ();
   return 0;
 }