[gcc r15-586] make -freg-struct-return visibly a negative alias of -fpcc-struct-return

2024-05-16 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:b7483de99536c05983129d9ca28b53b575861078

commit r15-586-gb7483de99536c05983129d9ca28b53b575861078
Author: Alexandre Oliva 
Date:   Fri May 17 00:45:45 2024 -0300

make -freg-struct-return visibly a negative alias of -fpcc-struct-return

The fact that both options accept negative forms suggests that maybe
they aren't negative forms of each other.  They are, but that isn't
clear even by examining common.opt.  Use NegativeAlias to make it
abundantly clear.

The 'Optimization' keyword next to freg-struct-return was the only
thing that caused flag_pcc_struct_return to be a per-function flag,
and ipa-inline relied on that.  After making it an alias, the
Optimization keyword was no longer operational.  I'm not sure it was
sensible or desirable for flag_pcc_struct_return to be a per-function
setting, but this patch does not intend to change behavior.


for  gcc/ChangeLog

* common.opt (freg-struct-return): Make it explicitly
fpcc-struct-return's NegativeAlias.  Copy Optimization...
(freg-struct-return): ... here.

Diff:
---
 gcc/common.opt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 40cab3cb36a3..40d90817b868 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2412,7 +2412,7 @@ Common RejectNegative Joined UInteger Optimization
 -fpack-struct= Set initial maximum structure member alignment.
 
 fpcc-struct-return
-Common Var(flag_pcc_struct_return,1) Init(DEFAULT_PCC_STRUCT_RETURN)
+Common Var(flag_pcc_struct_return,1) Init(DEFAULT_PCC_STRUCT_RETURN) 
Optimization
 Return small aggregates in memory, not registers.
 
 fpeel-loops
@@ -2602,7 +2602,7 @@ Common Var(flag_record_gcc_switches)
 Record gcc command line switches in the object file.
 
 freg-struct-return
-Common Var(flag_pcc_struct_return,0) Optimization
+Common NegativeAlias Alias(fpcc_struct_return) Optimization
 Return small aggregates in registers.
 
 fregmove


[gcc r15-585] RISC-V: Cleanup some temporally files [NFC]

2024-05-16 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:d477d683d5c6db90c80d348c795709ae6444ba7a

commit r15-585-gd477d683d5c6db90c80d348c795709ae6444ba7a
Author: Pan Li 
Date:   Fri May 17 07:45:19 2024 +0800

RISC-V: Cleanup some temporally files [NFC]

Just notice some temporally files under gcc/config/riscv,
deleted as useless.

* Empty file j.
* Vim swap file.

gcc/ChangeLog:

* config/riscv/.riscv.cc.swo: Removed.
* config/riscv/j: Removed.

Signed-off-by: Pan Li 

Diff:
---
 gcc/config/riscv/.riscv.cc.swo | Bin 417792 -> 0 bytes
 gcc/config/riscv/j |   0
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/gcc/config/riscv/.riscv.cc.swo b/gcc/config/riscv/.riscv.cc.swo
deleted file mode 100644
index 77ed37353bee..
Binary files a/gcc/config/riscv/.riscv.cc.swo and /dev/null differ
diff --git a/gcc/config/riscv/j b/gcc/config/riscv/j
deleted file mode 100644
index e69de29bb2d1..


[gcc r14-10213] Update gcc sv.po

2024-05-16 Thread Joseph Myers via Gcc-cvs
https://gcc.gnu.org/g:81c627d47c2063b7f143c974e9733ce43c0d142e

commit r14-10213-g81c627d47c2063b7f143c974e9733ce43c0d142e
Author: Joseph Myers 
Date:   Thu May 16 21:21:48 2024 +

Update gcc sv.po

* sv.po: Update.

Diff:
---
 gcc/po/sv.po | 514 +--
 1 file changed, 185 insertions(+), 329 deletions(-)

diff --git a/gcc/po/sv.po b/gcc/po/sv.po
index c28ce798df8d..9151df652e0d 100644
--- a/gcc/po/sv.po
+++ b/gcc/po/sv.po
@@ -29,10 +29,10 @@
 # thunksnutt
 msgid ""
 msgstr ""
-"Project-Id-Version: gcc 14.1-b20240218\n"
+"Project-Id-Version: gcc 14.1.0\n"
 "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n;
 "POT-Creation-Date: 2024-05-02 19:44+\n"
-"PO-Revision-Date: 2024-04-10 22:53+0200\n"
+"PO-Revision-Date: 2024-05-16 22:03+0200\n"
 "Last-Translator: Göran Uddeborg \n"
 "Language-Team: Swedish \n"
 "Language: sv\n"
@@ -1652,7 +1652,7 @@ msgstr "Varna för typkonvertering som slänger 
kvalificerare."
 #: c-family/c.opt:519
 #, no-c-format
 msgid "Warn about a cast to reference type that does not use a related 
user-defined conversion function."
-msgstr ""
+msgstr "Varna för en typkonvertering till en referenstyp som inte använder en 
relaterad användardefinierad konverteringsfunktion."
 
 #: c-family/c.opt:523 c-family/c.opt:527
 #, no-c-format
@@ -1977,10 +1977,9 @@ msgid "Warn when __builtin_frame_address or 
__builtin_return_address is used uns
 msgstr "Varna när __builtin_frame_address eller __builtin_return_address 
används osäkert."
 
 #: c-family/c.opt:811
-#, fuzzy, no-c-format
-#| msgid "global module fragment contents must be from preprocessor inclusion"
+#, no-c-format
 msgid "Warn about the global module fragment not containing only preprocessing 
directives."
-msgstr "globala modulfragments innehåll måste komma från 
preprocessorinkludering"
+msgstr "Varna för att det globala modulfragmentet inte endast innehåller 
preprocessordirektiv."
 
 #: c-family/c.opt:815
 #, no-c-format
@@ -2508,8 +2507,7 @@ msgid "Warn about suspicious length parameters to certain 
string functions if th
 msgstr "Varna för misstänkta längdparametrar till vissa strängfunktioner om 
argumentet använder sizeof."
 
 #: c-family/c.opt:1323
-#, fuzzy, no-c-format
-#| msgid "Warn about inproper usages of flexible array members according to 
the level of -fstrict-flex-arrays."
+#, no-c-format
 msgid "Warn about improper usages of flexible array members according to the 
level of -fstrict-flex-arrays."
 msgstr "Varna för felaktig användning av flexibla vektorelement enligt nivån 
på -fstrict-flex-arrays."
 
@@ -4136,14 +4134,12 @@ msgid "turn on internal debugging of the compiler 
(internal switch)"
 msgstr "slå på intern felsökning av kompilatorn (intern flagga)"
 
 #: m2/lang.opt:95
-#, fuzzy, no-c-format
-#| msgid "turn on internal debugging of the compiler (internal switch)"
+#, no-c-format
 msgid "turn on tracing of procedure line numbers (internal switch)"
-msgstr "slå på intern felsökning av kompilatorn (intern flagga)"
+msgstr "slå på spårning av procedurers radnummer (intern flagga)"
 
 #: m2/lang.opt:99
-#, fuzzy, no-c-format
-#| msgid "recognise the specified suffix as a definition module filename"
+#, no-c-format
 msgid "recognize the specified suffix as a definition module filename"
 msgstr "känn igen det angivna suffixet som ett definitionsmudulsfilnamn"
 
@@ -4188,10 +4184,9 @@ msgid "set all location values to a specific value 
(internal switch)"
 msgstr "sätt alla platsvärden till ett specifikt värde (intern flagga)"
 
 #: m2/lang.opt:135
-#, fuzzy, no-c-format
-#| msgid "turn on internal debugging of the compiler (internal switch)"
+#, no-c-format
 msgid "turn on internal debug tracing for quad,token,line,all (internal 
switch)"
-msgstr "slå på intern felsökning av kompilatorn (intern flagga)"
+msgstr "slå på intern felsökningsspårning för quad,token,line,all (intern 
flagga)"
 
 #: m2/lang.opt:139
 #, no-c-format
@@ -4234,8 +4229,7 @@ msgid "compile all implementation modules and program 
module at once"
 msgstr "kompilera alla implementationsmoduler och programmoduler på en gång"
 
 #: m2/lang.opt:175
-#, fuzzy, no-c-format
-#| msgid "recognise the specified suffix as implementation and module 
filenames"
+#, no-c-format
 msgid "recognize the specified suffix as implementation and module filenames"
 msgstr "känn igen det angivna suffixet som implementation och modulfilnamn"
 
@@ -4340,8 +4334,7 @@ msgid "optimize non var unbounded parameters by passing 
it by reference, providi
 msgstr "optimera icke-var obegränsade parametrar genom att skicka dem via 
referens, förutsatt att den inte skrivs till i den anropade proceduren."
 
 #: m2/lang.opt:263
-#, fuzzy, no-c-format
-#| msgid "orders the initialization/finalializations for scaffold-static or 
force linking of modules if scaffold-dynamic"
+#, no-c-format
 msgid "orders the initialization/finalizations for scaffold-static or force 
linking of modules 

[gcc r15-584] Update gcc sv.po

2024-05-16 Thread Joseph Myers via Gcc-cvs
https://gcc.gnu.org/g:0b2c333e1a3c0bb800add1daab5b6fc8ba5c1cef

commit r15-584-g0b2c333e1a3c0bb800add1daab5b6fc8ba5c1cef
Author: Joseph Myers 
Date:   Thu May 16 21:20:36 2024 +

Update gcc sv.po

* sv.po: Update.

Diff:
---
 gcc/po/sv.po | 514 +--
 1 file changed, 185 insertions(+), 329 deletions(-)

diff --git a/gcc/po/sv.po b/gcc/po/sv.po
index c28ce798df8d..9151df652e0d 100644
--- a/gcc/po/sv.po
+++ b/gcc/po/sv.po
@@ -29,10 +29,10 @@
 # thunksnutt
 msgid ""
 msgstr ""
-"Project-Id-Version: gcc 14.1-b20240218\n"
+"Project-Id-Version: gcc 14.1.0\n"
 "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n;
 "POT-Creation-Date: 2024-05-02 19:44+\n"
-"PO-Revision-Date: 2024-04-10 22:53+0200\n"
+"PO-Revision-Date: 2024-05-16 22:03+0200\n"
 "Last-Translator: Göran Uddeborg \n"
 "Language-Team: Swedish \n"
 "Language: sv\n"
@@ -1652,7 +1652,7 @@ msgstr "Varna för typkonvertering som slänger 
kvalificerare."
 #: c-family/c.opt:519
 #, no-c-format
 msgid "Warn about a cast to reference type that does not use a related 
user-defined conversion function."
-msgstr ""
+msgstr "Varna för en typkonvertering till en referenstyp som inte använder en 
relaterad användardefinierad konverteringsfunktion."
 
 #: c-family/c.opt:523 c-family/c.opt:527
 #, no-c-format
@@ -1977,10 +1977,9 @@ msgid "Warn when __builtin_frame_address or 
__builtin_return_address is used uns
 msgstr "Varna när __builtin_frame_address eller __builtin_return_address 
används osäkert."
 
 #: c-family/c.opt:811
-#, fuzzy, no-c-format
-#| msgid "global module fragment contents must be from preprocessor inclusion"
+#, no-c-format
 msgid "Warn about the global module fragment not containing only preprocessing 
directives."
-msgstr "globala modulfragments innehåll måste komma från 
preprocessorinkludering"
+msgstr "Varna för att det globala modulfragmentet inte endast innehåller 
preprocessordirektiv."
 
 #: c-family/c.opt:815
 #, no-c-format
@@ -2508,8 +2507,7 @@ msgid "Warn about suspicious length parameters to certain 
string functions if th
 msgstr "Varna för misstänkta längdparametrar till vissa strängfunktioner om 
argumentet använder sizeof."
 
 #: c-family/c.opt:1323
-#, fuzzy, no-c-format
-#| msgid "Warn about inproper usages of flexible array members according to 
the level of -fstrict-flex-arrays."
+#, no-c-format
 msgid "Warn about improper usages of flexible array members according to the 
level of -fstrict-flex-arrays."
 msgstr "Varna för felaktig användning av flexibla vektorelement enligt nivån 
på -fstrict-flex-arrays."
 
@@ -4136,14 +4134,12 @@ msgid "turn on internal debugging of the compiler 
(internal switch)"
 msgstr "slå på intern felsökning av kompilatorn (intern flagga)"
 
 #: m2/lang.opt:95
-#, fuzzy, no-c-format
-#| msgid "turn on internal debugging of the compiler (internal switch)"
+#, no-c-format
 msgid "turn on tracing of procedure line numbers (internal switch)"
-msgstr "slå på intern felsökning av kompilatorn (intern flagga)"
+msgstr "slå på spårning av procedurers radnummer (intern flagga)"
 
 #: m2/lang.opt:99
-#, fuzzy, no-c-format
-#| msgid "recognise the specified suffix as a definition module filename"
+#, no-c-format
 msgid "recognize the specified suffix as a definition module filename"
 msgstr "känn igen det angivna suffixet som ett definitionsmudulsfilnamn"
 
@@ -4188,10 +4184,9 @@ msgid "set all location values to a specific value 
(internal switch)"
 msgstr "sätt alla platsvärden till ett specifikt värde (intern flagga)"
 
 #: m2/lang.opt:135
-#, fuzzy, no-c-format
-#| msgid "turn on internal debugging of the compiler (internal switch)"
+#, no-c-format
 msgid "turn on internal debug tracing for quad,token,line,all (internal 
switch)"
-msgstr "slå på intern felsökning av kompilatorn (intern flagga)"
+msgstr "slå på intern felsökningsspårning för quad,token,line,all (intern 
flagga)"
 
 #: m2/lang.opt:139
 #, no-c-format
@@ -4234,8 +4229,7 @@ msgid "compile all implementation modules and program 
module at once"
 msgstr "kompilera alla implementationsmoduler och programmoduler på en gång"
 
 #: m2/lang.opt:175
-#, fuzzy, no-c-format
-#| msgid "recognise the specified suffix as implementation and module 
filenames"
+#, no-c-format
 msgid "recognize the specified suffix as implementation and module filenames"
 msgstr "känn igen det angivna suffixet som implementation och modulfilnamn"
 
@@ -4340,8 +4334,7 @@ msgid "optimize non var unbounded parameters by passing 
it by reference, providi
 msgstr "optimera icke-var obegränsade parametrar genom att skicka dem via 
referens, förutsatt att den inte skrivs till i den anropade proceduren."
 
 #: m2/lang.opt:263
-#, fuzzy, no-c-format
-#| msgid "orders the initialization/finalializations for scaffold-static or 
force linking of modules if scaffold-dynamic"
+#, no-c-format
 msgid "orders the initialization/finalizations for scaffold-static or force 
linking of modules 

[gcc r15-583] RISC-V: Enable vectorizable early exit testsuite

2024-05-16 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:556e777298dac8574533935000c57335c5232921

commit r15-583-g556e777298dac8574533935000c57335c5232921
Author: Pan Li 
Date:   Thu May 16 10:04:10 2024 +0800

RISC-V: Enable vectorizable early exit testsuite

After we supported vectorizable early exit in RISC-V,  we would like to
enable the gcc vect test for vectorizable early test.

The vect-early-break_124-pr114403.c failed to vectorize for now.
Because that the __builtin_memcpy with 8 bytes failed to folded into
int64 assignment during ccp1.  We will improve that first and mark
this as xfail for RISC-V.

The below tests are passed for this patch:
1. The riscv fully regression tests.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/slp-mask-store-1.c: Add pragma novector as it will
have 2 times LOOP VECTORIZED in RISC-V.
* gcc.dg/vect/vect-early-break_124-pr114403.c: Xfail for the
riscv backend.
* lib/target-supports.exp: Add RISC-V backend.

Signed-off-by: Pan Li 

Diff:
---
 gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c  | 2 ++
 gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c | 2 +-
 gcc/testsuite/lib/target-supports.exp | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c 
b/gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c
index fdd9032da98a..2f80bf89e5e6 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c
@@ -28,6 +28,8 @@ main ()
 
   if (__builtin_memcmp (x, res, sizeof (x)) != 0)
 abort ();
+
+#pragma GCC novector
   for (int i = 0; i < 32; ++i)
 if (flag[i] != 0 && flag[i] != 1)
   abort ();
diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c 
b/gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c
index 51abf245ccb5..101ae1e0eaa1 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c
@@ -2,7 +2,7 @@
 /* { dg-require-effective-target vect_early_break_hw } */
 /* { dg-require-effective-target vect_long_long } */
 
-/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { xfail riscv*-*-* } } 
} */
 
 #include "tree-vect.h"
 
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 6f5d477b1288..ec9baa4f32a3 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -4099,6 +4099,7 @@ proc check_effective_target_vect_early_break { } {
|| [check_effective_target_arm_v8_neon_ok]
|| [check_effective_target_sse4]
|| [istarget amdgcn-*-*]
+   || [check_effective_target_riscv_v]
}}]
 }
 
@@ -4114,6 +4115,7 @@ proc check_effective_target_vect_early_break_hw { } {
|| [check_effective_target_arm_v8_neon_hw]
|| [check_sse4_hw_available]
|| [istarget amdgcn-*-*]
+   || [check_effective_target_riscv_v_ok]
}}]
 }


[gcc r15-582] RISC-V: Implement vectorizable early exit with vcond_mask_len

2024-05-16 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:6c1de786e53a11150feb16ba990d0d6c6fd910db

commit r15-582-g6c1de786e53a11150feb16ba990d0d6c6fd910db
Author: Pan Li 
Date:   Thu May 16 10:02:40 2024 +0800

RISC-V: Implement vectorizable early exit with vcond_mask_len

After we support the loop lens for the vectorizable,  we would like to
implement the feature for the RISC-V target.  Given below example:

unsigned vect_a[1923];
unsigned vect_b[1923];

void test (unsigned limit, int n)
{
  for (int i = 0; i < n; i++)
{
  vect_b[i] = limit + i;

  if (vect_a[i] > limit)
{
  ret = vect_b[i];
  return ret;
}

  vect_a[i] = limit;
}
}

Before this patch:
  ...
.L8:
  swa3,0(a5)
  addiw a0,a0,1
  addi  a4,a4,4
  addi  a5,a5,4
  beq   a1,a0,.L2
.L4:
  swa0,0(a4)
  lwa2,0(a5)
  bleu  a2,a3,.L8
  ret

After this patch:
  ...
.L5:
  vsetvli   a5,a3,e8,mf4,ta,ma
  vmv1r.v   v4,v2
  vsetvli   t4,zero,e32,m1,ta,ma
  vmv.v.x   v1,a5
  vadd.vv   v2,v2,v1
  vsetvli   zero,a5,e32,m1,ta,ma
  vadd.vv   v5,v4,v3
  slli  a6,a5,2
  vle32.v   v1,0(t1)
  vmsltu.vv v1,v3,v1
  vcpop.m   t4,v1
  beq   t4,zero,.L4
  vmv.x.s   a4,v4
.L3:
  ...

The below tests are passed for this patch:
1. The riscv fully regression tests.

gcc/ChangeLog:

* 
config/riscv/autovec-opt.md(*vcond_mask_len_popcount_):
New pattern of vcond_mask_len_popcount for vector bool mode.
* config/riscv/autovec.md (vcond_mask_len_): New pattern of
vcond_mask_len for vector bool mode.
(cbranch4): New pattern for vector bool mode.
* config/riscv/vector-iterators.md: Add new unspec 
UNSPEC_SELECT_MASK.
* config/riscv/vector.md (@pred_popcount): Add VLS 
mode
to popcount pattern.
(@pred_popcount): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/early-break-1.c: New test.
* gcc.target/riscv/rvv/autovec/early-break-2.c: New test.

Signed-off-by: Pan Li 

Diff:
---
 gcc/config/riscv/autovec-opt.md| 33 
 gcc/config/riscv/autovec.md| 61 ++
 gcc/config/riscv/vector-iterators.md   |  1 +
 gcc/config/riscv/vector.md | 18 +++
 .../gcc.target/riscv/rvv/autovec/early-break-1.c   | 34 
 .../gcc.target/riscv/rvv/autovec/early-break-2.c   | 37 +
 6 files changed, 175 insertions(+), 9 deletions(-)

diff --git a/gcc/config/riscv/autovec-opt.md b/gcc/config/riscv/autovec-opt.md
index 645dc53d8680..04f85d8e4553 100644
--- a/gcc/config/riscv/autovec-opt.md
+++ b/gcc/config/riscv/autovec-opt.md
@@ -1436,3 +1436,36 @@
 DONE;
   }
   [(set_attr "type" "vmalu")])
+
+;; Optimization pattern for early break auto-vectorization
+;; vcond_mask_len (mask, ones, zeros, len, bias) + vlmax popcount
+;; -> non vlmax popcount (mask, len)
+(define_insn_and_split "*vcond_mask_len_popcount_"
+  [(set (match_operand:P 0 "register_operand")
+(popcount:P
+ (unspec:VB_VLS [
+  (unspec:VB_VLS [
+   (match_operand:VB_VLS 1 "register_operand")
+   (match_operand:VB_VLS 2 "const_1_operand")
+   (match_operand:VB_VLS 3 "const_0_operand")
+   (match_operand 4 "autovec_length_operand")
+   (match_operand 5 "const_0_operand")] UNSPEC_SELECT_MASK)
+  (match_operand 6 "autovec_length_operand")
+  (const_int 1)
+  (reg:SI VL_REGNUM)
+  (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)))]
+  "TARGET_VECTOR
+   && can_create_pseudo_p ()
+   && riscv_vector::get_vector_mode (Pmode, GET_MODE_NUNITS 
(mode)).exists ()"
+  "#"
+  "&& 1"
+  [(const_int 0)]
+  {
+riscv_vector::emit_nonvlmax_insn (
+   code_for_pred_popcount (mode, Pmode),
+   riscv_vector::CPOP_OP,
+   operands, operands[4]);
+DONE;
+  }
+  [(set_attr "type" "vector")]
+)
diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md
index aa1ae0fe075b..1ee3c8052fb4 100644
--- a/gcc/config/riscv/autovec.md
+++ b/gcc/config/riscv/autovec.md
@@ -2612,3 +2612,64 @@
 DONE;
   }
 )
+
+;; =
+;; == Early break auto-vectorization patterns
+;; =
+
+;; vcond_mask_len (mask, 1s, 0s, len, bias)
+;; => mask[i] = mask[i] && i < len ? 1 : 0
+(define_insn_and_split "vcond_mask_len_"
+  [(set (match_operand:VB 0 "register_operand")
+(unspec: VB [
+ (match_operand:VB 1 "register_operand")
+ (match_operand:VB 2 "const_1_operand")
+ (match_operand:VB 3 "const_0_operand")
+ (match_operand 4 "autovec_length_operand")
+ (match_operand 5 "const_0_operand")] 

[gcc r15-581] Fix points_to_local_or_readonly_memory_p wrt TARGET_MEM_REF

2024-05-16 Thread Jan Hubicka via Gcc-cvs
https://gcc.gnu.org/g:96d53252aefcbc2fe419c4c3b4bcd3fc03d4d187

commit r15-581-g96d53252aefcbc2fe419c4c3b4bcd3fc03d4d187
Author: Jan Hubicka 
Date:   Thu May 16 15:33:55 2024 +0200

Fix points_to_local_or_readonly_memory_p wrt TARGET_MEM_REF

TARGET_MEM_REF can be used to offset constant base into a memory object (to
produce lea instruction).  This confuses 
points_to_local_or_readonly_memory_p
which treats the constant address as a base of the access.

Bootstrapped/regtsted x86_64-linux, comitted.
Honza

gcc/ChangeLog:

PR ipa/113787
* ipa-fnsummary.cc (points_to_local_or_readonly_memory_p): Do not
look into TARGET_MEM_REFS with constant opreand 0.

gcc/testsuite/ChangeLog:

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

Diff:
---
 gcc/ipa-fnsummary.cc   |  4 ++-
 gcc/testsuite/gcc.c-torture/execute/pr113787.c | 38 ++
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc
index 07a853f78e39..2faf23892971 100644
--- a/gcc/ipa-fnsummary.cc
+++ b/gcc/ipa-fnsummary.cc
@@ -2648,7 +2648,9 @@ points_to_local_or_readonly_memory_p (tree t)
return true;
   return !ptr_deref_may_alias_global_p (t, false);
 }
-  if (TREE_CODE (t) == ADDR_EXPR)
+  if (TREE_CODE (t) == ADDR_EXPR
+  && (TREE_CODE (TREE_OPERAND (t, 0)) != TARGET_MEM_REF
+ || TREE_CODE (TREE_OPERAND (TREE_OPERAND (t, 0), 0)) != INTEGER_CST))
 return refs_local_or_readonly_memory_p (TREE_OPERAND (t, 0));
   return false;
 }
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr113787.c 
b/gcc/testsuite/gcc.c-torture/execute/pr113787.c
new file mode 100644
index ..702b6c35fc68
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr113787.c
@@ -0,0 +1,38 @@
+void foo(int x, int y, int z, int d, int *buf)
+{
+  for(int i = z; i < y-z; ++i)
+for(int j = 0; j < d; ++j)
+  /* buf[x(i+1) + j] = buf[x(i+1)-j-1] */
+  buf[i*x+(x-z+j)] = buf[i*x+(x-z-1-j)];
+}
+
+void bar(int x, int y, int z, int d, int *buf)
+{
+  for(int i = 0; i < d; ++i)
+for(int j = z; j < x-z; ++j)
+  /* buf[j+(y+i)*x] = buf[j+(y-1-i)*x] */
+  buf[j+(y-z+i)*x] = buf[j+(y-z-1-i)*x];
+}
+
+__attribute__((noipa))
+void baz(int x, int y, int d, int *buf)
+{
+  foo(x, y, 0, d, buf);
+  bar(x, y, 0, d, buf);
+}
+
+int main(void)
+{
+  int a[] = { 1, 2, 3 };
+  baz (1, 2, 1, a);
+  /* foo does:
+ buf[1] = buf[0];
+ buf[2] = buf[1];
+
+ bar does:
+ buf[2] = buf[1]; (no-op)
+ so we should have { 1, 1, 1 }.  */
+  for (int i = 0; i < 3; i++)
+if (a[i] != 1)
+  __builtin_abort ();
+}


[gcc r15-580] tree-optimization/13962 - handle ptr-ptr compares in ptrs_compare_unequal

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:f3e5f4c58591f5dacdd14a65ec47bbe310df02a0

commit r15-580-gf3e5f4c58591f5dacdd14a65ec47bbe310df02a0
Author: Richard Biener 
Date:   Mon Mar 11 11:17:32 2024 +0100

tree-optimization/13962 - handle ptr-ptr compares in ptrs_compare_unequal

Now that we handle pt.null conservatively we can implement the missing
tracking of constant pool entries (aka STRING_CST) and handle
ptr-ptr compares using points-to info in ptrs_compare_unequal.

PR tree-optimization/13962
PR tree-optimization/96564
* tree-ssa-alias.h (pt_solution::const_pool): New flag.
* tree-ssa-alias.cc (ptrs_compare_unequal): Handle pointer-pointer
compares.
(dump_points_to_solution): Dump the const_pool flag, fix guard
of flag dumping.
* gimple-pretty-print.cc (pp_points_to_solution): Likewise.
* tree-ssa-structalias.cc (find_what_var_points_to): Set
the const_pool flag for STRING.
(pt_solution_ior_into): Handle the const_pool flag.
(ipa_escaped_pt): Initialize it.

* gcc.dg/tree-ssa/alias-39.c: New testcase.
* g++.dg/vect/pr68145.cc: Use -fno-tree-pta to avoid UB
to manifest in transforms no longer vectorizing this testcase
for an ICE.

Diff:
---
 gcc/gimple-pretty-print.cc   |  5 -
 gcc/testsuite/g++.dg/vect/pr68145.cc |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/alias-39.c | 12 
 gcc/tree-ssa-alias.cc| 30 ++
 gcc/tree-ssa-alias.h |  5 +
 gcc/tree-ssa-structalias.cc  |  6 +++---
 6 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc
index abda8871f97f..a71e1e0efc77 100644
--- a/gcc/gimple-pretty-print.cc
+++ b/gcc/gimple-pretty-print.cc
@@ -822,6 +822,8 @@ pp_points_to_solution (pretty_printer *buffer, const 
pt_solution *pt)
 pp_string (buffer, "unit-escaped ");
   if (pt->null)
 pp_string (buffer, "null ");
+  if (pt->const_pool)
+pp_string (buffer, "const-pool ");
   if (pt->vars
   && !bitmap_empty_p (pt->vars))
 {
@@ -838,7 +840,8 @@ pp_points_to_solution (pretty_printer *buffer, const 
pt_solution *pt)
   if (pt->vars_contains_nonlocal
  || pt->vars_contains_escaped
  || pt->vars_contains_escaped_heap
- || pt->vars_contains_restrict)
+ || pt->vars_contains_restrict
+ || pt->vars_contains_interposable)
{
  const char *comma = "";
  pp_string (buffer, " (");
diff --git a/gcc/testsuite/g++.dg/vect/pr68145.cc 
b/gcc/testsuite/g++.dg/vect/pr68145.cc
index 8a1e10ee7833..8d3502b0bf4e 100644
--- a/gcc/testsuite/g++.dg/vect/pr68145.cc
+++ b/gcc/testsuite/g++.dg/vect/pr68145.cc
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-additional-options "-Wno-return-type" } */
+/* { dg-additional-options "-fno-tree-pta -Wno-return-type" } */
 
 struct A {
   bool operator()(int p1, int p2) { return p1 && p2; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-39.c 
b/gcc/testsuite/gcc.dg/tree-ssa/alias-39.c
new file mode 100644
index ..3b452893f6b1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-39.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-forwprop3" } */
+
+static int a, b;
+int foo (int n, int which)
+{
+  void *p = __builtin_malloc (n);
+  void *q = which ?  : 
+  return p == q;
+}
+
+/* { dg-final { scan-tree-dump "return 0;" "forwprop3" } } */
diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index 96301bbde7fa..6d31fc836917 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -484,9 +484,27 @@ ptrs_compare_unequal (tree ptr1, tree ptr2)
}
   return !pt_solution_includes (>pt, obj1);
 }
-
-  /* ???  We'd like to handle ptr1 != NULL and ptr1 != ptr2
- but those require pt.null to be conservatively correct.  */
+  else if (TREE_CODE (ptr1) == SSA_NAME)
+{
+  struct ptr_info_def *pi1 = SSA_NAME_PTR_INFO (ptr1);
+  if (!pi1
+ || pi1->pt.vars_contains_restrict
+ || pi1->pt.vars_contains_interposable)
+   return false;
+  if (integer_zerop (ptr2) && !pi1->pt.null)
+   return true;
+  if (TREE_CODE (ptr2) == SSA_NAME)
+   {
+ struct ptr_info_def *pi2 = SSA_NAME_PTR_INFO (ptr2);
+ if (!pi2
+ || pi2->pt.vars_contains_restrict
+ || pi2->pt.vars_contains_interposable)
+   return false;
+ if ((!pi1->pt.null || !pi2->pt.null)
+ && (!pi1->pt.const_pool || !pi2->pt.const_pool))
+   return !pt_solutions_intersect (>pt, >pt);
+   }
+}
 
   return false;
 }
@@ -636,6 +654,9 @@ dump_points_to_solution (FILE *file, struct pt_solution *pt)
   if (pt->null)
 fprintf (file, ", points-to NULL");
 
+  if (pt->const_pool)
+fprintf (file, ", points-to 

[gcc r15-579] wrong code with points-to and volatile

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:a9251ab3c91c8c559d0306838575a666ae62dff4

commit r15-579-ga9251ab3c91c8c559d0306838575a666ae62dff4
Author: Richard Biener 
Date:   Thu May 16 12:35:28 2024 +0200

wrong code with points-to and volatile

The following fixes points-to analysis which ignores the fact that
volatile qualified refs can result in any pointer.

* tree-ssa-structalias.cc (get_constraint_for_1): For
volatile referenced or decls use ANYTHING.

* gcc.dg/tree-ssa/alias-38.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/alias-38.c | 14 ++
 gcc/tree-ssa-structalias.cc  |  7 +++
 2 files changed, 21 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-38.c 
b/gcc/testsuite/gcc.dg/tree-ssa/alias-38.c
new file mode 100644
index ..a5c414934735
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-38.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int x;
+int y;
+
+int main ()
+{
+  int *volatile p = 
+  return (p != );
+}
+
+/* { dg-final { scan-tree-dump " != " "optimized" } } */
+/* { dg-final { scan-tree-dump-not "return 1;" "optimized" } } */
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index bb59c6a7c023..0bac1a1f045a 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -3575,6 +3575,10 @@ get_constraint_for_1 (tree t, vec *results, bool 
address_p,
   }
 case tcc_reference:
   {
+   if (TREE_THIS_VOLATILE (t))
+ /* Fall back to anything.  */
+ break;
+
switch (TREE_CODE (t))
  {
  case MEM_REF:
@@ -3676,6 +3680,9 @@ get_constraint_for_1 (tree t, vec *results, bool 
address_p,
   }
 case tcc_declaration:
   {
+   if (VAR_P (t) && TREE_THIS_VOLATILE (t))
+ /* Fall back to anything.  */
+ break;
get_constraint_for_ssa_var (t, results, address_p);
return;
   }


[gcc r15-578] Vect: Support loop len in vectorizable early exit

2024-05-16 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:57f8a2f67c1536be23231808ab00613ab69193ed

commit r15-578-g57f8a2f67c1536be23231808ab00613ab69193ed
Author: Pan Li 
Date:   Thu May 16 09:58:13 2024 +0800

Vect: Support loop len in vectorizable early exit

This patch adds early break auto-vectorization support for target which
use length on partial vectorization.  Consider this following example:

unsigned vect_a[802];
unsigned vect_b[802];

void test (unsigned x, int n)
{
  for (int i = 0; i < n; i++)
  {
vect_b[i] = x + i;

if (vect_a[i] > x)
  break;

vect_a[i] = x;
  }
}

We use VCOND_MASK_LEN to simulate the generate (mask && i < len + bias).
And then the IR of RVV looks like below:

  ...
  _87 = .SELECT_VL (ivtmp_85, POLY_INT_CST [32, 32]);
  _55 = (int) _87;
  ...
  mask_patt_6.13_69 = vect_cst__62 < vect__3.12_67;
  vec_len_mask_72 = .VCOND_MASK_LEN (mask_patt_6.13_69, { -1, ... }, \
{0, ... }, _87, 0);
  if (vec_len_mask_72 != { 0, ... })
goto ; [5.50%]
  else
goto ; [94.50%]

The below tests are passed for this patch:
1. The riscv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

gcc/ChangeLog:

* tree-vect-loop.cc (vect_gen_loop_len_mask): New func to gen
the loop len mask.
* tree-vect-stmts.cc (vectorizable_early_exit): Invoke the
vect_gen_loop_len_mask for 1 or more stmt(s).
* tree-vectorizer.h (vect_gen_loop_len_mask): New func decl
for vect_gen_loop_len_mask.

Signed-off-by: Pan Li 

Diff:
---
 gcc/tree-vect-loop.cc  | 27 +++
 gcc/tree-vect-stmts.cc | 17 +++--
 gcc/tree-vectorizer.h  |  4 
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 361aec064884..83c0544b6aa5 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -11416,6 +11416,33 @@ vect_get_loop_len (loop_vec_info loop_vinfo, 
gimple_stmt_iterator *gsi,
   return loop_len;
 }
 
+/* Generate the tree for the loop len mask and return it.  Given the lens,
+   nvectors, vectype, index and factor to gen the len mask as below.
+
+   tree len_mask = VCOND_MASK_LEN (compare_mask, ones, zero, len, bias)
+*/
+tree
+vect_gen_loop_len_mask (loop_vec_info loop_vinfo, gimple_stmt_iterator *gsi,
+   gimple_stmt_iterator *cond_gsi, vec_loop_lens *lens,
+   unsigned int nvectors, tree vectype, tree stmt,
+   unsigned int index, unsigned int factor)
+{
+  tree all_one_mask = build_all_ones_cst (vectype);
+  tree all_zero_mask = build_zero_cst (vectype);
+  tree len = vect_get_loop_len (loop_vinfo, gsi, lens, nvectors, vectype, 
index,
+   factor);
+  tree bias = build_int_cst (intQI_type_node,
+LOOP_VINFO_PARTIAL_LOAD_STORE_BIAS (loop_vinfo));
+  tree len_mask = make_temp_ssa_name (TREE_TYPE (stmt), NULL, "vec_len_mask");
+  gcall *call = gimple_build_call_internal (IFN_VCOND_MASK_LEN, 5, stmt,
+   all_one_mask, all_zero_mask, len,
+   bias);
+  gimple_call_set_lhs (call, len_mask);
+  gsi_insert_before (cond_gsi, call, GSI_SAME_STMT);
+
+  return len_mask;
+}
+
 /* Scale profiling counters by estimation for LOOP which is vectorized
by factor VF.
If FLAT is true, the loop we started with had unrealistically flat
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index b8a71605f1bc..672959501bb7 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -12895,7 +12895,9 @@ vectorizable_early_exit (vec_info *vinfo, stmt_vec_info 
stmt_info,
 ncopies = vect_get_num_copies (loop_vinfo, vectype);
 
   vec_loop_masks *masks = _VINFO_MASKS (loop_vinfo);
+  vec_loop_lens *lens = _VINFO_LENS (loop_vinfo);
   bool masked_loop_p = LOOP_VINFO_FULLY_MASKED_P (loop_vinfo);
+  bool len_loop_p = LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo);
 
   /* Now build the new conditional.  Pattern gimple_conds get dropped during
  codegen so we must replace the original insn.  */
@@ -12959,12 +12961,11 @@ vectorizable_early_exit (vec_info *vinfo, 
stmt_vec_info stmt_info,
{
  if (direct_internal_fn_supported_p (IFN_VCOND_MASK_LEN, vectype,
  OPTIMIZE_FOR_SPEED))
-   return false;
+   vect_record_loop_len (loop_vinfo, lens, ncopies, vectype, 1);
  else
vect_record_loop_mask (loop_vinfo, masks, ncopies, vectype, NULL);
}
 
-
   return true;
 }
 
@@ -13017,6 +13018,15 @@ vectorizable_early_exit (vec_info *vinfo, 
stmt_vec_info stmt_info,
  stmts[i], _gsi);
workset.quick_push (stmt_mask);
  

[gcc r15-577] Vect: Support new IFN SAT_ADD for unsigned vector int

2024-05-16 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:d4dee347b3fe1982bab26485ff31cd039c9df010

commit r15-577-gd4dee347b3fe1982bab26485ff31cd039c9df010
Author: Pan Li 
Date:   Wed May 15 10:14:06 2024 +0800

Vect: Support new IFN SAT_ADD for unsigned vector int

For vectorize, we leverage the existing vect pattern recog to find
the pattern similar to scalar and let the vectorizer to perform
the rest part for standard name usadd3 in vector mode.
The riscv vector backend have insn "Vector Single-Width Saturating
Add and Subtract" which can be leveraged when expand the usadd3
in vector mode.  For example:

void vec_sat_add_u64 (uint64_t *out, uint64_t *x, uint64_t *y, unsigned n)
{
  unsigned i;

  for (i = 0; i < n; i++)
out[i] = (x[i] + y[i]) | (- (uint64_t)((uint64_t)(x[i] + y[i]) < x[i]));
}

Before this patch:
void vec_sat_add_u64 (uint64_t *out, uint64_t *x, uint64_t *y, unsigned n)
{
  ...
  _80 = .SELECT_VL (ivtmp_78, POLY_INT_CST [2, 2]);
  ivtmp_58 = _80 * 8;
  vect__4.7_61 = .MASK_LEN_LOAD (vectp_x.5_59, 64B, { -1, ... }, _80, 0);
  vect__6.10_65 = .MASK_LEN_LOAD (vectp_y.8_63, 64B, { -1, ... }, _80, 0);
  vect__7.11_66 = vect__4.7_61 + vect__6.10_65;
  mask__8.12_67 = vect__4.7_61 > vect__7.11_66;
  vect__12.15_72 = .VCOND_MASK (mask__8.12_67, { 18446744073709551615,
... }, vect__7.11_66);
  .MASK_LEN_STORE (vectp_out.16_74, 64B, { -1, ... }, _80, 0, 
vect__12.15_72);
  vectp_x.5_60 = vectp_x.5_59 + ivtmp_58;
  vectp_y.8_64 = vectp_y.8_63 + ivtmp_58;
  vectp_out.16_75 = vectp_out.16_74 + ivtmp_58;
  ivtmp_79 = ivtmp_78 - _80;
  ...
}

After this patch:
void vec_sat_add_u64 (uint64_t *out, uint64_t *x, uint64_t *y, unsigned n)
{
  ...
  _62 = .SELECT_VL (ivtmp_60, POLY_INT_CST [2, 2]);
  ivtmp_46 = _62 * 8;
  vect__4.7_49 = .MASK_LEN_LOAD (vectp_x.5_47, 64B, { -1, ... }, _62, 0);
  vect__6.10_53 = .MASK_LEN_LOAD (vectp_y.8_51, 64B, { -1, ... }, _62, 0);
  vect__12.11_54 = .SAT_ADD (vect__4.7_49, vect__6.10_53);
  .MASK_LEN_STORE (vectp_out.12_56, 64B, { -1, ... }, _62, 0, 
vect__12.11_54);
  ...
}

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

PR target/51492
PR target/112600

gcc/ChangeLog:

* tree-vect-patterns.cc (gimple_unsigned_integer_sat_add): New
func decl generated by match.pd match.
(vect_recog_sat_add_pattern): New func impl to recog the pattern
for unsigned SAT_ADD.

Signed-off-by: Pan Li 

Diff:
---
 gcc/tree-vect-patterns.cc | 52 +++
 1 file changed, 52 insertions(+)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index dfb7d8005262..a313dc64643e 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -4487,6 +4487,57 @@ vect_recog_mult_pattern (vec_info *vinfo,
   return pattern_stmt;
 }
 
+extern bool gimple_unsigned_integer_sat_add (tree, tree*, tree (*)(tree));
+
+/*
+ * Try to detect saturation add pattern (SAT_ADD), aka below gimple:
+ *   _7 = _4 + _6;
+ *   _8 = _4 > _7;
+ *   _9 = (long unsigned int) _8;
+ *   _10 = -_9;
+ *   _12 = _7 | _10;
+ *
+ * And then simplied to
+ *   _12 = .SAT_ADD (_4, _6);
+ */
+
+static gimple *
+vect_recog_sat_add_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo,
+   tree *type_out)
+{
+  gimple *last_stmt = STMT_VINFO_STMT (stmt_vinfo);
+
+  if (!is_gimple_assign (last_stmt))
+return NULL;
+
+  tree res_ops[2];
+  tree lhs = gimple_assign_lhs (last_stmt);
+
+  if (gimple_unsigned_integer_sat_add (lhs, res_ops, NULL))
+{
+  tree itype = TREE_TYPE (res_ops[0]);
+  tree vtype = get_vectype_for_scalar_type (vinfo, itype);
+
+  if (vtype != NULL_TREE
+   && direct_internal_fn_supported_p (IFN_SAT_ADD, vtype,
+  OPTIMIZE_FOR_BOTH))
+   {
+ *type_out = vtype;
+ gcall *call = gimple_build_call_internal (IFN_SAT_ADD, 2, res_ops[0],
+   res_ops[1]);
+
+ gimple_call_set_lhs (call, vect_recog_temp_ssa_var (itype, NULL));
+ gimple_call_set_nothrow (call, /* nothrow_p */ false);
+ gimple_set_location (call, gimple_location (last_stmt));
+
+ vect_pattern_detected ("vect_recog_sat_add_pattern", last_stmt);
+ return call;
+   }
+}
+
+  return NULL;
+}
+
 /* Detect a signed division by a constant that wouldn't be
otherwise vectorized:
 
@@ -6987,6 +7038,7 @@ static vect_recog_func vect_vect_recog_func_ptrs[] = {
   { vect_recog_vector_vector_shift_pattern, "vector_vector_shift" },
   { vect_recog_divmod_pattern, "divmod" },
   { vect_recog_mult_pattern, "mult" },
+  { 

[gcc r15-576] Internal-fn: Support new IFN SAT_ADD for unsigned scalar int

2024-05-16 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:52b0536710ff3f3ace72ab00ce9ef6c630cd1183

commit r15-576-g52b0536710ff3f3ace72ab00ce9ef6c630cd1183
Author: Pan Li 
Date:   Wed May 15 10:14:05 2024 +0800

Internal-fn: Support new IFN SAT_ADD for unsigned scalar int

This patch would like to add the middle-end presentation for the
saturation add.  Aka set the result of add to the max when overflow.
It will take the pattern similar as below.

SAT_ADD (x, y) => (x + y) | (-(TYPE)((TYPE)(x + y) < x))

Take uint8_t as example, we will have:

* SAT_ADD (1, 254)   => 255.
* SAT_ADD (1, 255)   => 255.
* SAT_ADD (2, 255)   => 255.
* SAT_ADD (255, 255) => 255.

Given below example for the unsigned scalar integer uint64_t:

uint64_t sat_add_u64 (uint64_t x, uint64_t y)
{
  return (x + y) | (- (uint64_t)((uint64_t)(x + y) < x));
}

Before this patch:
uint64_t sat_add_uint64_t (uint64_t x, uint64_t y)
{
  long unsigned int _1;
  _Bool _2;
  long unsigned int _3;
  long unsigned int _4;
  uint64_t _7;
  long unsigned int _10;
  __complex__ long unsigned int _11;

;;   basic block 2, loop depth 0
;;pred:   ENTRY
  _11 = .ADD_OVERFLOW (x_5(D), y_6(D));
  _1 = REALPART_EXPR <_11>;
  _10 = IMAGPART_EXPR <_11>;
  _2 = _10 != 0;
  _3 = (long unsigned int) _2;
  _4 = -_3;
  _7 = _1 | _4;
  return _7;
;;succ:   EXIT

}

After this patch:
uint64_t sat_add_uint64_t (uint64_t x, uint64_t y)
{
  uint64_t _7;

;;   basic block 2, loop depth 0
;;pred:   ENTRY
  _7 = .SAT_ADD (x_5(D), y_6(D)); [tail call]
  return _7;
;;succ:   EXIT
}

The below tests are passed for this patch:
1. The riscv fully regression tests.
3. The x86 bootstrap tests.
4. The x86 fully regression tests.

PR target/51492
PR target/112600

gcc/ChangeLog:

* internal-fn.cc (commutative_binary_fn_p): Add type IFN_SAT_ADD
to the return true switch case(s).
* internal-fn.def (SAT_ADD):  Add new signed optab SAT_ADD.
* match.pd: Add unsigned SAT_ADD match(es).
* optabs.def (OPTAB_NL): Remove fixed-point limitation for
us/ssadd.
* tree-ssa-math-opts.cc (gimple_unsigned_integer_sat_add): New
extern func decl generated in match.pd match.
(match_saturation_arith): New func impl to match the saturation 
arith.
(math_opts_dom_walker::after_dom_children): Try match saturation
arith when IOR expr.

Signed-off-by: Pan Li 

Diff:
---
 gcc/internal-fn.cc|  1 +
 gcc/internal-fn.def   |  2 ++
 gcc/match.pd  | 51 +++
 gcc/optabs.def|  4 ++--
 gcc/tree-ssa-math-opts.cc | 32 +
 5 files changed, 88 insertions(+), 2 deletions(-)

diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
index 0a7053c2286c..73045ca8c8c1 100644
--- a/gcc/internal-fn.cc
+++ b/gcc/internal-fn.cc
@@ -4202,6 +4202,7 @@ commutative_binary_fn_p (internal_fn fn)
 case IFN_UBSAN_CHECK_MUL:
 case IFN_ADD_OVERFLOW:
 case IFN_MUL_OVERFLOW:
+case IFN_SAT_ADD:
 case IFN_VEC_WIDEN_PLUS:
 case IFN_VEC_WIDEN_PLUS_LO:
 case IFN_VEC_WIDEN_PLUS_HI:
diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def
index 848bb9dbff3f..25badbb86e56 100644
--- a/gcc/internal-fn.def
+++ b/gcc/internal-fn.def
@@ -275,6 +275,8 @@ DEF_INTERNAL_SIGNED_OPTAB_FN (MULHS, ECF_CONST | 
ECF_NOTHROW, first,
 DEF_INTERNAL_SIGNED_OPTAB_FN (MULHRS, ECF_CONST | ECF_NOTHROW, first,
  smulhrs, umulhrs, binary)
 
+DEF_INTERNAL_SIGNED_OPTAB_FN (SAT_ADD, ECF_CONST, first, ssadd, usadd, binary)
+
 DEF_INTERNAL_COND_FN (ADD, ECF_CONST, add, binary)
 DEF_INTERNAL_COND_FN (SUB, ECF_CONST, sub, binary)
 DEF_INTERNAL_COND_FN (MUL, ECF_CONST, smul, binary)
diff --git a/gcc/match.pd b/gcc/match.pd
index 07e743ae464b..0f9c34fa8974 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3043,6 +3043,57 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|| POINTER_TYPE_P (itype))
   && wi::eq_p (wi::to_wide (int_cst), wi::max_value (itype))
 
+/* Unsigned Saturation Add */
+(match (usadd_left_part_1 @0 @1)
+ (plus:c @0 @1)
+ (if (INTEGRAL_TYPE_P (type)
+  && TYPE_UNSIGNED (TREE_TYPE (@0))
+  && types_match (type, TREE_TYPE (@0))
+  && types_match (type, TREE_TYPE (@1)
+
+(match (usadd_left_part_2 @0 @1)
+ (realpart (IFN_ADD_OVERFLOW:c @0 @1))
+ (if (INTEGRAL_TYPE_P (type)
+  && TYPE_UNSIGNED (TREE_TYPE (@0))
+  && types_match (type, TREE_TYPE (@0))
+  && types_match (type, TREE_TYPE (@1)
+
+(match (usadd_right_part_1 @0 @1)
+ (negate (convert (lt (plus:c @0 @1) @0)))
+ (if (INTEGRAL_TYPE_P (type)
+  && TYPE_UNSIGNED (TREE_TYPE (@0))
+  && 

gcc-wwwdocs branch master updated. ed9ceba9b8b038f0e0f333798da7abe046679d0c

2024-05-16 Thread Eric Botcazou via Gcc-cvs-wwwdocs
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gcc-wwwdocs".

The branch, master has been updated
   via  ed9ceba9b8b038f0e0f333798da7abe046679d0c (commit)
  from  8f193930f0beb38d06b143bcc1d5632f457e0cdf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -
commit ed9ceba9b8b038f0e0f333798da7abe046679d0c
Author: Eric Botcazou 
Date:   Thu May 16 12:38:25 2024 +0200

Document reimplementation of GNU threads library on Windows (PR web/115105)

diff --git a/htdocs/gcc-13/changes.html b/htdocs/gcc-13/changes.html
index e324b782..3ab4a101 100644
--- a/htdocs/gcc-13/changes.html
+++ b/htdocs/gcc-13/changes.html
@@ -770,8 +770,17 @@ You may also want to check out our
 
 
 
-
-
+Windows
+
+  The GNU threads library used by the win32 thread model has
+  been reimplemented using direct Win32 API calls, except for the 
Objective-C
+  specific subset.  It requires Windows XP/Server 2003 or later.  The new
+  implementation also adds the support needed for the C++11 threads, using
+  again direct Win32 API calls; this additional layer requires Windows
+  Vista/Server 2008 or later.  It is recommended to use a recent version of
+  MinGW-W64 in conjunction with the win32 thread model.
+  
+
 
 
 

---

Summary of changes:
 htdocs/gcc-13/changes.html | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
gcc-wwwdocs


[gcc r15-575] Revert "Revert: "Enable prange support.""

2024-05-16 Thread Aldy Hernandez via Gcc-cvs
https://gcc.gnu.org/g:da73261ce7731be7f2b164f1db796878cdc23365

commit r15-575-gda73261ce7731be7f2b164f1db796878cdc23365
Author: Aldy Hernandez 
Date:   Fri May 10 00:38:51 2024 +0200

Revert "Revert: "Enable prange support.""

This reverts commit d7bb8eaade3cd3aa70715c8567b4d7b08098e699 and enables 
prange
support again.

Diff:
---
 gcc/gimple-range-cache.cc |  4 ++--
 gcc/gimple-range-fold.cc  |  4 ++--
 gcc/gimple-range-fold.h   |  2 +-
 gcc/gimple-range-infer.cc |  2 +-
 gcc/gimple-range-op.cc|  2 +-
 gcc/gimple-range-path.cc  |  2 +-
 gcc/gimple-ssa-warn-access.cc |  2 +-
 gcc/ipa-cp.h  |  2 +-
 gcc/range-op-ptr.cc   |  4 
 gcc/range-op.cc   | 18 --
 gcc/tree-ssa-structalias.cc   |  2 +-
 gcc/value-range.cc|  1 +
 gcc/value-range.h |  4 ++--
 13 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 72ac25523117..bdd2832873aa 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -274,10 +274,10 @@ sbr_sparse_bitmap::sbr_sparse_bitmap (tree t, 
vrange_allocator *allocator,
   // Pre-cache zero and non-zero values for pointers.
   if (POINTER_TYPE_P (t))
 {
-  int_range<2> nonzero;
+  prange nonzero;
   nonzero.set_nonzero (t);
   m_range[1] = m_range_allocator->clone (nonzero);
-  int_range<2> zero;
+  prange zero;
   zero.set_zero (t);
   m_range[2] = m_range_allocator->clone (zero);
 }
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 9c4ad1ee7b91..a9c8c4d03e63 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -597,7 +597,7 @@ fold_using_range::fold_stmt (vrange , gimple *s, 
fur_source , tree name)
   // Process addresses.
   if (gimple_code (s) == GIMPLE_ASSIGN
   && gimple_assign_rhs_code (s) == ADDR_EXPR)
-return range_of_address (as_a  (r), s, src);
+return range_of_address (as_a  (r), s, src);
 
   gimple_range_op_handler handler (s);
   if (handler)
@@ -757,7 +757,7 @@ fold_using_range::range_of_range_op (vrange ,
 // If a range cannot be calculated, set it to VARYING and return true.
 
 bool
-fold_using_range::range_of_address (irange , gimple *stmt, fur_source )
+fold_using_range::range_of_address (prange , gimple *stmt, fur_source )
 {
   gcc_checking_assert (gimple_code (stmt) == GIMPLE_ASSIGN);
   gcc_checking_assert (gimple_assign_rhs_code (stmt) == ADDR_EXPR);
diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h
index 7cbe15d05e53..c7c599bfc939 100644
--- a/gcc/gimple-range-fold.h
+++ b/gcc/gimple-range-fold.h
@@ -157,7 +157,7 @@ protected:
  fur_source );
   bool range_of_call (vrange , gcall *call, fur_source );
   bool range_of_cond_expr (vrange , gassign* cond, fur_source );
-  bool range_of_address (irange , gimple *s, fur_source );
+  bool range_of_address (prange , gimple *s, fur_source );
   bool range_of_phi (vrange , gphi *phi, fur_source );
   void range_of_ssa_name_with_loop_info (vrange &, tree, class loop *, gphi *,
 fur_source );
diff --git a/gcc/gimple-range-infer.cc b/gcc/gimple-range-infer.cc
index c8e8b9b60ac1..d5e1aa142758 100644
--- a/gcc/gimple-range-infer.cc
+++ b/gcc/gimple-range-infer.cc
@@ -123,7 +123,7 @@ gimple_infer_range::add_nonzero (tree name)
 {
   if (!gimple_range_ssa_p (name))
 return;
-  int_range<2> nz;
+  prange nz;
   nz.set_nonzero (TREE_TYPE (name));
   add_range (name, nz);
 }
diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
index 7321342b00de..aec3f39ec0e8 100644
--- a/gcc/gimple-range-op.cc
+++ b/gcc/gimple-range-op.cc
@@ -1107,7 +1107,7 @@ class cfn_strlen : public range_operator
 {
 public:
   using range_operator::fold_range;
-  virtual bool fold_range (irange , tree type, const irange &,
+  virtual bool fold_range (irange , tree type, const prange &,
   const irange &, relation_trio) const
   {
 wide_int max = irange_val_max (ptrdiff_type_node);
diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index 96c6ac6b6a50..f1a12f76144c 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -443,7 +443,7 @@ path_range_query::compute_ranges_in_block (basic_block bb)
 void
 path_range_query::adjust_for_non_null_uses (basic_block bb)
 {
-  int_range_max r;
+  prange r;
   bitmap_iterator bi;
   unsigned i;
 
diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index 2c10d19e7f36..0cd5b6d6ef48 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -4213,7 +4213,7 @@ pass_waccess::check_pointer_uses (gimple *stmt, tree ptr,
 where the realloc call is known to have failed are valid.
 Ignore pointers that nothing is known about.  Those could
 have escaped along with their nullness.  */
- value_range 

[gcc r15-574] Cleanup prange sanity checks.

2024-05-16 Thread Aldy Hernandez via Gcc-cvs
https://gcc.gnu.org/g:b8e3574e68310f68116f157a35d5650600d13718

commit r15-574-gb8e3574e68310f68116f157a35d5650600d13718
Author: Aldy Hernandez 
Date:   Thu May 16 09:47:56 2024 +0200

Cleanup prange sanity checks.

The pointers_handled_p() code was a temporary sanity check, and not
even a good one, since we have a cleaner way of checking type
mismatches with operand_check_p.  This patch removes all the code, and
adds an explicit type check for relational operators, which are the
main problem in PR114985.

Adding this check makes it clear where the type mismatch is happening
in IPA, even without prange.  I've added code to skip the range
folding if the types don't match what the operator expects.  In order
to reproduce the latent bug, just remove the operand_check_p calls.

Tested on x86-64 and ppc64le with and without prange support.

gcc/ChangeLog:

PR tree-optimization/114985
* gimple-range-op.cc: Remove pointers_handled_p.
* ipa-cp.cc (ipa_value_range_from_jfunc): Skip range folding if
operands don't match.
(propagate_vr_across_jump_function): Same.
* range-op-mixed.h: Remove pointers_handled_p and tweak
operand_check_p.
* range-op-ptr.cc (range_operator::pointers_handled_p): Remove.
(pointer_plus_operator::pointers_handled_p): Remove.
(class operator_pointer_diff): Remove pointers_handled_p.
(operator_pointer_diff::pointers_handled_p): Remove.
(operator_identity::pointers_handled_p): Remove.
(operator_cst::pointers_handled_p): Remove.
(operator_cast::pointers_handled_p): Remove.
(operator_min::pointers_handled_p): Remove.
(operator_max::pointers_handled_p): Remove.
(operator_addr_expr::pointers_handled_p): Remove.
(operator_bitwise_and::pointers_handled_p): Remove.
(operator_bitwise_or::pointers_handled_p): Remove.
(operator_equal::pointers_handled_p): Remove.
(operator_not_equal::pointers_handled_p): Remove.
(operator_lt::pointers_handled_p): Remove.
(operator_le::pointers_handled_p): Remove.
(operator_gt::pointers_handled_p): Remove.
(operator_ge::pointers_handled_p): Remove.
* range-op.cc (TRAP_ON_UNHANDLED_POINTER_OPERATORS): Remove.
(range_op_handler::lhs_op1_relation): Remove pointers_handled_p 
checks.
(range_op_handler::lhs_op2_relation): Same.
(range_op_handler::op1_op2_relation): Same.
* range-op.h: Remove RO_* declarations.

Diff:
---
 gcc/gimple-range-op.cc |  24 -
 gcc/ipa-cp.cc  |  12 +++
 gcc/range-op-mixed.h   |  38 +++-
 gcc/range-op-ptr.cc| 259 -
 gcc/range-op.cc|  43 +---
 gcc/range-op.h |  17 
 6 files changed, 25 insertions(+), 368 deletions(-)

diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
index 55dfbb23ce22..7321342b00de 100644
--- a/gcc/gimple-range-op.cc
+++ b/gcc/gimple-range-op.cc
@@ -329,19 +329,6 @@ public:
 r = lhs;
 return true;
   }
-  virtual bool pointers_handled_p (range_op_dispatch_type type,
-  unsigned dispatch) const
-  {
-switch (type)
-  {
-  case DISPATCH_FOLD_RANGE:
-   return dispatch == RO_PPP;
-  case DISPATCH_OP1_RANGE:
-   return dispatch == RO_PPP;
-  default:
-   return true;
-  }
-  }
 } op_cfn_pass_through_arg1;
 
 // Implement range operator for CFN_BUILT_IN_SIGNBIT.
@@ -1132,17 +1119,6 @@ public:
 r.set (type, wi::zero (TYPE_PRECISION (type)), max - 2);
 return true;
   }
-  virtual bool pointers_handled_p (range_op_dispatch_type type,
-  unsigned dispatch) const
-  {
-switch (type)
-  {
-  case DISPATCH_FOLD_RANGE:
-   return dispatch == RO_IPI;
-  default:
-   return true;
-  }
-  }
 } op_cfn_strlen;
 
 
diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 5781f50c8546..09cab7618226 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -1740,6 +1740,11 @@ ipa_value_range_from_jfunc (vrange ,
 
  if (!handler
  || !op_res.supports_type_p (vr_type)
+ /* Sometimes we try to fold comparison operators using a
+pointer type to hold the result instead of a boolean
+type.  Avoid trapping in the sanity check in
+fold_range until this is fixed.  */
+ || !handler.operand_check_p (vr_type, srcvr.type (), op_vr.type 
())
  || !handler.fold_range (op_res, vr_type, srcvr, op_vr))
op_res.set_varying (vr_type);
 
@@ -2547,6 +2552,13 @@ propagate_vr_across_jump_function (cgraph_edge *cs, 
ipa_jump_func *jfunc,
 
  if (!handler
  || !ipa_supports_p (operand_type)
+ 

[gcc r15-573] Use a boolean type when folding conditionals in simplify_using_ranges.

2024-05-16 Thread Aldy Hernandez via Gcc-cvs
https://gcc.gnu.org/g:f6bed6d3fcc13880ffa786b6c616e2306efe2bf3

commit r15-573-gf6bed6d3fcc13880ffa786b6c616e2306efe2bf3
Author: Aldy Hernandez 
Date:   Thu May 16 09:22:55 2024 +0200

Use a boolean type when folding conditionals in simplify_using_ranges.

In adding some traps for PR114985 I noticed that the conditional
folding code in simplify_using_ranges was using the wrong type.  This
cleans up the oversight.

gcc/ChangeLog:

PR tree-optimization/114985
* vr-values.cc (simplify_using_ranges::fold_cond_with_ops): Use
boolean type when folding conditionals.

Diff:
---
 gcc/vr-values.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc
index 0572bf6c8c73..e6ea9592574f 100644
--- a/gcc/vr-values.cc
+++ b/gcc/vr-values.cc
@@ -316,10 +316,9 @@ simplify_using_ranges::fold_cond_with_ops (enum tree_code 
code,
   || !query->range_of_expr (r1, op1, s))
 return NULL_TREE;
 
-  tree type = TREE_TYPE (op0);
   int_range<1> res;
   range_op_handler handler (code);
-  if (handler && handler.fold_range (res, type, r0, r1))
+  if (handler && handler.fold_range (res, boolean_type_node, r0, r1))
 {
   if (res == range_true ())
return boolean_true_node;


[gcc r12-10450] tree-optimization/114027 - conditional reduction chain

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:6661a7c098a46eff4afc98b55c89e3a71d63d674

commit r12-10450-g6661a7c098a46eff4afc98b55c89e3a71d63d674
Author: Richard Biener 
Date:   Thu Feb 22 10:50:12 2024 +0100

tree-optimization/114027 - conditional reduction chain

When we classify a conditional reduction chain as CONST_COND_REDUCTION
we fail to verify all involved conditionals have the same constant.
That's a quite unlikely situation so the following simply disables
such classification when there's more than one reduction statement.

PR tree-optimization/114027
* tree-vect-loop.cc (vecctorizable_reduction): Use optimized
condition reduction classification only for single-element
chains.

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

(cherry picked from commit 549f251f055e3a0b0084189a3012c4f15d635e75)

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr114027.c | 26 ++
 gcc/tree-vect-loop.cc| 11 ++-
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr114027.c 
b/gcc/testsuite/gcc.dg/vect/pr114027.c
new file mode 100644
index ..ead9cdd982d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114027.c
@@ -0,0 +1,26 @@
+#include "tree-vect.h"
+
+int __attribute__((noipa))
+foo (int *f, int n)
+{
+  int res = 0;
+  for (int i = 0; i < n; ++i)
+{
+  if (f[2*i])
+res = 2;
+  if (f[2*i+1])
+res = -2;
+}
+  return res;
+}
+
+int f[] = { 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 0 };
+
+int
+main ()
+{
+  if (foo (f, 16) != 2)
+__builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index e1681047d9da..86ee9e449e19 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6850,17 +6850,18 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
  < GET_MODE_SIZE (SCALAR_TYPE_MODE (TREE_TYPE 
(vectype_op[i]))
vectype_in = vectype_op[i];
 
-  if (op.code == COND_EXPR)
+  /* Record how the non-reduction-def value of COND_EXPR is defined.
+???  For a chain of multiple CONDs we'd have to match them up all.  */
+  if (op.code == COND_EXPR && reduc_chain_length == 1)
{
- /* Record how the non-reduction-def value of COND_EXPR is defined.  */
  if (dt == vect_constant_def)
{
  cond_reduc_dt = dt;
  cond_reduc_val = op.ops[i];
}
- if (dt == vect_induction_def
- && def_stmt_info
- && is_nonwrapping_integer_induction (def_stmt_info, loop))
+ else if (dt == vect_induction_def
+  && def_stmt_info
+  && is_nonwrapping_integer_induction (def_stmt_info, loop))
{
  cond_reduc_dt = dt;
  cond_stmt_vinfo = def_stmt_info;


[gcc r12-10451] tree-optimization/114027 - fix testcase

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:2d650c041d37a3df2bec46a67e42f9976d7fd2bf

commit r12-10451-g2d650c041d37a3df2bec46a67e42f9976d7fd2bf
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 ead9cdd982d7..b3f3e30e15fc 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 r12-10448] tree-optimization/114231 - use patterns for BB SLP discovery root stmts

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:a7b1d814da0aa2e7331c56180264a8b786012971

commit r12-10448-ga7b1d814da0aa2e7331c56180264a8b786012971
Author: Richard Biener 
Date:   Tue Mar 5 10:55:56 2024 +0100

tree-optimization/114231 - use patterns for BB SLP discovery root stmts

The following makes sure to use recognized patterns when vectorizing
roots during BB SLP discovery.  We need to apply those late since
during root discovery we've not yet done pattern recognition.
All parts of the vectorizer assume patterns get used, for the testcase
we mix this up when doing live lane computation.

PR tree-optimization/114231
* tree-vect-slp.cc (vect_analyze_slp): Lookup patterns when
processing a BB SLP root.

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

(cherry picked from commit 04fffbaa87997ac893a9aa68b674c938ba3ecddb)

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr114231.c | 12 
 gcc/tree-vect-slp.cc |  4 
 2 files changed, 16 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/vect/pr114231.c 
b/gcc/testsuite/gcc.dg/vect/pr114231.c
new file mode 100644
index ..5e3a81039188
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114231.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+void f(long*);
+int ff[2];
+void f2(long, long, unsigned long);
+void k(unsigned long x, unsigned long y)
+{
+  long t = x >> ff[0];
+  long t1 = ff[1];
+  unsigned long t2 = y >> ff[0];
+  f2(t1, t+t2, t2);
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 7f9fbb9f3d01..f33e85337abd 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3410,6 +3410,10 @@ vect_analyze_slp (vec_info *vinfo, unsigned 
max_tree_size)
   for (unsigned i = 0; i < bb_vinfo->roots.length (); ++i)
{
  vect_location = bb_vinfo->roots[i].roots[0]->stmt;
+ /* Apply patterns.  */
+ for (unsigned j = 0; j < bb_vinfo->roots[i].stmts.length (); ++j)
+   bb_vinfo->roots[i].stmts[j]
+ = vect_stmt_to_vectorize (bb_vinfo->roots[i].stmts[j]);
  if (vect_build_slp_instance (bb_vinfo, bb_vinfo->roots[i].kind,
   bb_vinfo->roots[i].stmts,
   bb_vinfo->roots[i].roots,


[gcc r12-10449] tree-optimization/114375 - disallow SLP discovery of permuted mask loads

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:c1b21855e131bb818aedc953f403812b494917fc

commit r12-10449-gc1b21855e131bb818aedc953f403812b494917fc
Author: Richard Biener 
Date:   Mon Mar 18 12:39:03 2024 +0100

tree-optimization/114375 - disallow SLP discovery of permuted mask loads

We cannot currently handle permutations of mask loads in code generation
or permute optimization.  But we simply drop any permutation on the
floor, so the following instead rejects the SLP build rather than
producing wrong-code.  I've also made sure to reject them in
vectorizable_load for completeness.

PR tree-optimization/114375
* tree-vect-slp.cc (vect_build_slp_tree_2): Compute the
load permutation for masked loads but reject it when any
such is necessary.
* tree-vect-stmts.cc (vectorizable_load): Reject masked
VMAT_ELEMENTWISE and VMAT_STRIDED_SLP as those are not
supported.

* gcc.dg/vect/vect-pr114375.c: New testcase.

(cherry picked from commit 4f2a35a76cca503749c696e7772d2e8eadc77ba5)

Diff:
---
 gcc/testsuite/gcc.dg/vect/vect-pr114375.c | 44 +++
 gcc/tree-vect-slp.cc  | 34 +++-
 gcc/tree-vect-stmts.cc|  8 ++
 3 files changed, 79 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr114375.c 
b/gcc/testsuite/gcc.dg/vect/vect-pr114375.c
new file mode 100644
index ..1e1cb0123d07
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-pr114375.c
@@ -0,0 +1,44 @@
+/* { dg-additional-options "-mavx2" { target avx2_runtime } } */
+
+#include "tree-vect.h"
+
+int a[512];
+int b[512];
+int c[512];
+
+void __attribute__((noipa))
+foo(int * __restrict p)
+{
+  for (int i = 0; i < 64; ++i)
+{
+  int tem = 2, tem2 = 2;
+  if (a[4*i + 1])
+tem = p[4*i];
+  if (a[4*i])
+tem2 = p[4*i + 2];
+  b[2*i] = tem2;
+  b[2*i+1] = tem;
+  if (a[4*i + 2])
+tem = p[4*i + 1];
+  if (a[4*i + 3])
+tem2 = p[4*i + 3];
+  c[2*i] = tem2;
+  c[2*i+1] = tem;
+}
+}
+int main()
+{
+  check_vect ();
+
+  for (int i = 0; i < 512; ++i)
+a[i] = (i >> 1) & 1;
+
+  foo (a);
+
+  if (c[0] != 1 || c[1] != 0 || c[2] != 1 || c[3] != 0
+  || b[0] != 2 || b[1] != 2 || b[2] != 2 || b[3] != 2)
+abort ();
+
+  return 0;
+}
+
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index f33e85337abd..26c989cbff9a 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -1722,10 +1722,8 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
   if (STMT_VINFO_GROUPED_ACCESS (stmt_info)
   && DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info)))
 {
-  if (gcall *stmt = dyn_cast  (stmt_info->stmt))
-   gcc_assert (gimple_call_internal_p (stmt, IFN_MASK_LOAD)
-   || gimple_call_internal_p (stmt, IFN_GATHER_LOAD)
-   || gimple_call_internal_p (stmt, IFN_MASK_GATHER_LOAD));
+  if (STMT_VINFO_GATHER_SCATTER_P (stmt_info))
+   gcc_assert (DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info)));
   else
{
  *max_nunits = this_max_nunits;
@@ -1741,15 +1739,37 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
  load_permutation.create (group_size);
  stmt_vec_info first_stmt_info
= DR_GROUP_FIRST_ELEMENT (SLP_TREE_SCALAR_STMTS (node)[0]);
+ bool any_permute = false;
  FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), j, load_info)
{
  int load_place = vect_get_place_in_interleaving_chain
  (load_info, first_stmt_info);
  gcc_assert (load_place != -1);
- load_permutation.safe_push (load_place);
+ any_permute |= load_place != j;
+ load_permutation.quick_push (load_place);
+   }
+
+ if (gcall *stmt = dyn_cast  (stmt_info->stmt))
+   {
+ gcc_assert (gimple_call_internal_p (stmt, IFN_MASK_LOAD)
+ || gimple_call_internal_p (stmt, IFN_GATHER_LOAD)
+ || gimple_call_internal_p (stmt, 
IFN_MASK_GATHER_LOAD));
+ load_permutation.release ();
+ /* We cannot handle permuted masked loads, see PR114375.  */
+ if (any_permute
+ || (STMT_VINFO_GROUPED_ACCESS (stmt_info)
+ && DR_GROUP_SIZE (first_stmt_info) != group_size)
+ || STMT_VINFO_STRIDED_P (stmt_info))
+   {
+ matches[0] = false;
+ return NULL;
+   }
+   }
+ else
+   {
+ SLP_TREE_LOAD_PERMUTATION (node) = load_permutation;
+ return node;
}
- SLP_TREE_LOAD_PERMUTATION (node) = load_permutation;
- return node;
}
 }
   else if (gimple_assign_single_p (stmt_info->stmt)
diff --git a/gcc/tree-vect-stmts.cc 

[gcc r12-10447] middle-end/114734 - wrong code with expand_call_mem_ref

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:46b2e98983ebc62440c43217f2b3bbe72f8b0191

commit r12-10447-g46b2e98983ebc62440c43217f2b3bbe72f8b0191
Author: Richard Biener 
Date:   Fri Apr 26 15:47:13 2024 +0200

middle-end/114734 - wrong code with expand_call_mem_ref

When expand_call_mem_ref looks at the definition of the address
argument to eventually expand a _MEM_REF argument together
with a masked load it fails to honor constraints imposed by SSA
coalescing decisions.  The following fixes this.

PR middle-end/114734
* internal-fn.cc (expand_call_mem_ref): Use
get_gimple_for_ssa_name to get at the def stmt of the address
argument to honor SSA coalescing constraints.

(cherry picked from commit 20ebcaf826c91ddaf2aac35417ec1e5e6d31ad50)

Diff:
---
 gcc/internal-fn.cc | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
index 8b1733e20c44..db23f66b0219 100644
--- a/gcc/internal-fn.cc
+++ b/gcc/internal-fn.cc
@@ -52,6 +52,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "explow.h"
 #include "rtl-iter.h"
 #include "gimple-range.h"
+#include "tree-ssa-live.h"
+#include "tree-outof-ssa.h"
 
 /* For lang_hooks.types.type_for_mode.  */
 #include "langhooks.h"
@@ -2663,8 +2665,8 @@ expand_call_mem_ref (tree type, gcall *stmt, int index)
   tree tmp = addr;
   if (TREE_CODE (tmp) == SSA_NAME)
 {
-  gimple *def = SSA_NAME_DEF_STMT (tmp);
-  if (gimple_assign_single_p (def))
+  gimple *def = get_gimple_for_ssa_name (tmp);
+  if (def && gimple_assign_single_p (def))
tmp = gimple_assign_rhs1 (def);
 }


[gcc r12-10446] lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:42a0393655d8e4662ba001c3759cf00b639eddb9

commit r12-10446-g42a0393655d8e4662ba001c3759cf00b639eddb9
Author: Richard Biener 
Date:   Tue Apr 9 14:25:57 2024 +0200

lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile 
time

The following adjusts -flto option processing in lto-wrapper to have
link-time -flto override any compile time setting.

PR lto/114655
* lto-wrapper.cc (merge_flto_options): Add force argument.
(merge_and_complain): Do not force here.
(run_gcc): But here to make the link-time -flto option override
any compile-time one.

(cherry picked from commit 32fb04adae90a0ea68e64e8fc3cb04b613b2e9f3)

Diff:
---
 gcc/lto-wrapper.cc | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
index 155ccce57ae3..456636bd5dfe 100644
--- a/gcc/lto-wrapper.cc
+++ b/gcc/lto-wrapper.cc
@@ -193,15 +193,18 @@ find_option (vec , 
cl_decoded_option *option)
   return find_option (options, option->opt_index);
 }
 
-/* Merge -flto FOPTION into vector of DECODED_OPTIONS.  */
+/* Merge -flto FOPTION into vector of DECODED_OPTIONS.  If FORCE is true
+   then FOPTION overrides previous settings.  */
 
 static void
 merge_flto_options (vec _options,
-   cl_decoded_option *foption)
+   cl_decoded_option *foption, bool force)
 {
   int existing_opt = find_option (decoded_options, foption);
   if (existing_opt == -1)
 decoded_options.safe_push (*foption);
+  else if (force)
+decoded_options[existing_opt].arg = foption->arg;
   else
 {
   if (strcmp (foption->arg, decoded_options[existing_opt].arg) != 0)
@@ -466,7 +469,7 @@ merge_and_complain (vec _options,
  break;
 
case OPT_flto_:
- merge_flto_options (decoded_options, foption);
+ merge_flto_options (decoded_options, foption, false);
  break;
}
 }
@@ -1540,8 +1543,8 @@ run_gcc (unsigned argc, char *argv[])
  break;
 
case OPT_flto_:
- /* Merge linker -flto= option with what we have in IL files.  */
- merge_flto_options (fdecoded_options, option);
+ /* Override IL file settings with a linker -flto= option.  */
+ merge_flto_options (fdecoded_options, option, true);
  if (strcmp (option->arg, "jobserver") == 0)
jobserver_requested = true;
  break;


[gcc r12-10445] gcov-profile/114715 - missing coverage for switch

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:56415e39029012aa3675d3b4b71fb248cf43049e

commit r12-10445-g56415e39029012aa3675d3b4b71fb248cf43049e
Author: Richard Biener 
Date:   Mon Apr 15 11:09:17 2024 +0200

gcov-profile/114715 - missing coverage for switch

The following avoids missing coverage for the line of a switch statement
which happens when gimplification emits a BIND_EXPR wrapping the switch
as that prevents us from setting locations on the containing statements
via annotate_all_with_location.  Instead set the location of the GIMPLE
switch directly.

PR gcov-profile/114715
* gimplify.cc (gimplify_switch_expr): Set the location of the
GIMPLE switch.

* gcc.misc-tests/gcov-24.c: New testcase.

(cherry picked from commit 5a3cc62dbb45185dd1ca32caec80d57a320ec5a0)

Diff:
---
 gcc/gimplify.cc|  1 +
 gcc/testsuite/gcc.misc-tests/gcov-24.c | 30 ++
 2 files changed, 31 insertions(+)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 947fe570e1e7..9e7869770183 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -2764,6 +2764,7 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p)
 
   switch_stmt = gimple_build_switch (SWITCH_COND (switch_expr),
 default_case, labels);
+  gimple_set_location (switch_stmt, EXPR_LOCATION (switch_expr));
   /* For the benefit of -Wimplicit-fallthrough, if switch_body_seq
 ends with a GIMPLE_LABEL holding SWITCH_BREAK_LABEL_P LABEL_DECL,
 wrap the GIMPLE_SWITCH up to that GIMPLE_LABEL into a GIMPLE_BIND,
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-24.c 
b/gcc/testsuite/gcc.misc-tests/gcov-24.c
new file mode 100644
index ..395099bd7ae3
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-24.c
@@ -0,0 +1,30 @@
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int main()
+{
+  int a = 1;
+  int b = 2;
+  int c = -3;
+  switch(a) /* count(1) */
+{
+case 1: /* count(1) */
+c = 3;
+switch(b) { /* count(1) */
+  case 1: /* count(#) */
+  c = 4;
+  break;
+  case 2: /* count(1) */
+  c = 5;
+  break;
+}
+break;
+case 2: /* count(#) */
+c = 6;
+break;
+default: /* count(#) */
+break;
+}
+}
+
+/* { dg-final { run-gcov gcov-24.c } } */


[gcc r15-572] RISC-V: testsuite: Drop march-string in cmpmemsi/cpymemsi tests

2024-05-16 Thread Christoph Mテシllner via Gcc-cvs
https://gcc.gnu.org/g:b8b82bb05c10544da05cd0d3d39e6bc3763a8d9f

commit r15-572-gb8b82bb05c10544da05cd0d3d39e6bc3763a8d9f
Author: Christoph Müllner 
Date:   Thu May 16 09:53:47 2024 +0200

RISC-V: testsuite: Drop march-string in cmpmemsi/cpymemsi tests

The tests cmpmemsi-1.c and cpymemsi-1.c are execution ("dg-do run")
tests, which does not have any restrictions for the enabled extensions.
Further, no other listed options are required.
Let's drop the options, so that the test can also be executed on
non-f and non-d targets.  However, we need to set options to the
defaults without '-ansi', because the included test file uses the
'asm' keyword, which is not part of ANSI C.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/cmpmemsi-1.c: Drop options.
* gcc.target/riscv/cpymemsi-1.c: Likewise.

Signed-off-by: Christoph Müllner 

Diff:
---
 gcc/testsuite/gcc.target/riscv/cmpmemsi-1.c | 3 +--
 gcc/testsuite/gcc.target/riscv/cpymemsi-1.c | 4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/cmpmemsi-1.c 
b/gcc/testsuite/gcc.target/riscv/cmpmemsi-1.c
index d7e0bc474073..698f27d89fbf 100644
--- a/gcc/testsuite/gcc.target/riscv/cmpmemsi-1.c
+++ b/gcc/testsuite/gcc.target/riscv/cmpmemsi-1.c
@@ -1,6 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-march=rv32gc_zbb -save-temps -g0 -fno-lto" { target { rv32 } 
} } */
-/* { dg-options "-march=rv64gc_zbb -save-temps -g0 -fno-lto" { target { rv64 } 
} } */
+/* { dg-options "-pedantic-errors" } */
 /* { dg-timeout-factor 2 } */
 
 #include "../../gcc.dg/memcmp-1.c"
diff --git a/gcc/testsuite/gcc.target/riscv/cpymemsi-1.c 
b/gcc/testsuite/gcc.target/riscv/cpymemsi-1.c
index 983b564ccaf7..30e9f119bedc 100644
--- a/gcc/testsuite/gcc.target/riscv/cpymemsi-1.c
+++ b/gcc/testsuite/gcc.target/riscv/cpymemsi-1.c
@@ -1,7 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-march=rv32gc -save-temps -g0 -fno-lto" { target { rv32 } } } 
*/
-/* { dg-options "-march=rv64gc -save-temps -g0 -fno-lto" { target { rv64 } } } 
*/
-/* { dg-additional-options "-DRUN_FRACTION=11" { target simulator } } */
+/* { dg-options "-pedantic-errors" } */
 /* { dg-timeout-factor 2 } */
 
 #include "../../gcc.dg/memcmp-1.c"


[gcc r15-571] tree-optimization/79958 - make DSE track multiple paths

2024-05-16 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:1e0ae1f52741f7e0133661659ed2d210f939a398

commit r15-571-g1e0ae1f52741f7e0133661659ed2d210f939a398
Author: Richard Biener 
Date:   Wed May 15 18:32:37 2024 +0200

tree-optimization/79958 - make DSE track multiple paths

DSE currently gives up when the path we analyze forks.  This leads
to multiple missed dead store elimination PRs.  The following fixes
this by recursing for each path and maintaining the visited bitmap
to avoid visiting CFG re-merges multiple times.  The overall cost
is still limited by the same bound, it's just more likely we'll hit
the limit now.  The patch doesn't try to deal with byte tracking
once a path forks but drops info on the floor and only handling
fully dead stores in that case.

PR tree-optimization/79958
PR tree-optimization/109087
PR tree-optimization/100314
PR tree-optimization/114774
* tree-ssa-dse.cc (dse_classify_store): New forwarder.
(dse_classify_store): Add arguments cnt and visited, recurse
to track multiple paths when we end up with multiple defs.

* gcc.dg/tree-ssa/ssa-dse-48.c: New testcase.
* gcc.dg/tree-ssa/ssa-dse-49.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-50.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-51.c: Likewise.
* gcc.dg/graphite/pr80906.c: Avoid DSE of last data reference
in loop.
* g++.dg/ipa/devirt-24.C: Adjust for extra DSE.
* g++.dg/warn/Wuninitialized-pr107919-1.C: Use more important
-O2 optimization level, -O1 regresses.

Diff:
---
 gcc/testsuite/g++.dg/ipa/devirt-24.C   |  4 ++-
 .../g++.dg/warn/Wuninitialized-pr107919-1.C|  2 +-
 gcc/testsuite/gcc.dg/graphite/pr80906.c|  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-48.c | 17 
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-49.c | 18 +
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-50.c | 25 +
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-51.c | 24 +
 gcc/tree-ssa-dse.cc| 31 +++---
 8 files changed, 116 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/g++.dg/ipa/devirt-24.C 
b/gcc/testsuite/g++.dg/ipa/devirt-24.C
index 7b5b806dd05f..333c03cd8dd7 100644
--- a/gcc/testsuite/g++.dg/ipa/devirt-24.C
+++ b/gcc/testsuite/g++.dg/ipa/devirt-24.C
@@ -37,4 +37,6 @@ C *b = new (C);
   }
 }
 /* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known 
target" 1 "inline" { xfail *-*-* } } } */
-/* { dg-final { scan-ipa-dump-times "Aggregate passed by reference" 2 "cp"  } 
} */
+/* We used to have IPA CP see two aggregates passed to sort() but as the
+   first argument is unused DSE now elides the vptr initialization.  */
+/* { dg-final { scan-ipa-dump-times "Aggregate passed by reference" 1 "cp"  } 
} */
diff --git a/gcc/testsuite/g++.dg/warn/Wuninitialized-pr107919-1.C 
b/gcc/testsuite/g++.dg/warn/Wuninitialized-pr107919-1.C
index dd631dc8bfe7..067a44a462e1 100644
--- a/gcc/testsuite/g++.dg/warn/Wuninitialized-pr107919-1.C
+++ b/gcc/testsuite/g++.dg/warn/Wuninitialized-pr107919-1.C
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-require-effective-target c++17 }
-// { dg-options "-O -Wuninitialized" }
+// { dg-options "-O2 -Wuninitialized" }
 
 #include 
 #include 
diff --git a/gcc/testsuite/gcc.dg/graphite/pr80906.c 
b/gcc/testsuite/gcc.dg/graphite/pr80906.c
index 59c7f59cadff..ec3840834fc4 100644
--- a/gcc/testsuite/gcc.dg/graphite/pr80906.c
+++ b/gcc/testsuite/gcc.dg/graphite/pr80906.c
@@ -18,7 +18,7 @@ ec (int lh[][2])
  --bm;
if (bm != 0)
  --c5;
-   lh[0][0] = 0;
+   lh[hp][0] = 0;
m3 *= jv;
   }
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-48.c 
b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-48.c
new file mode 100644
index ..edfc62c7e4ab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-48.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-dse1-details" } */
+
+int a;
+int foo (void);
+int bar (void);
+
+void
+baz (void)
+{
+  int *b[6];
+  b[0] = 
+  if (foo ())
+a |= bar ();
+}
+
+/* { dg-final { scan-tree-dump "Deleted dead store: b\\\[0\\\] = " "dse1" } 
} */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-49.c 
b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-49.c
new file mode 100644
index ..1eec284a4159
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-49.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dce -fdump-tree-dse1-details" } */
+
+struct X { int i; };
+void bar ();
+void foo (int b)
+{
+  struct X x;
+  x.i = 1;
+  if (b)
+{
+  bar ();
+  __builtin_abort ();
+}
+  bar ();
+}
+
+/* { dg-final { scan-tree-dump "Deleted dead store: x.i = 1;" "dse1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-50.c 

[gcc r15-569] ada: Reset scope of top level object declaration during unnesting

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:f72988ac5ecfd56229374cbe76d867177ec5431d

commit r15-569-gf72988ac5ecfd56229374cbe76d867177ec5431d
Author: Marc Poulhiès 
Date:   Tue Feb 27 13:47:27 2024 +0100

ada: Reset scope of top level object declaration during unnesting

When unnesting, the compiler gathers elaboration code and wraps it with
a new dedicated procedure. While doing so, it resets the scopes of
entities that are wrapped to point to this new procedure. This change
also resets the scopes of N_Object_Declaration and
N_Object_Renaming_Declaration nodes only if an elaboration procedure
is needed.

gcc/ada/

* exp_ch7.adb (Reset_Scopes_To_Block_Elab_Proc): also reset scope
for object declarations.

Diff:
---
 gcc/ada/exp_ch7.adb | 31 +++
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 6d76572f405d..f9738e115f99 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -3646,9 +3646,10 @@ package body Exp_Ch7 is
   --  unnesting actions, which depend on proper setting of the Scope links
   --  to determine the nesting level of each subprogram.
 
-  ---
-  --  Find_Local_Scope --
-  ---
+  --
+  --  Reset_Scopes_To_Block_Elab_Proc --
+  --
+  Maybe_Reset_Scopes_For_Decl : constant Elist_Id := New_Elmt_List;
 
   procedure Reset_Scopes_To_Block_Elab_Proc (L : List_Id) is
  Id   : Entity_Id;
@@ -3707,7 +3708,8 @@ package body Exp_Ch7 is
  Next (Node);
   end loop;
 
-   --  Reset the Scope of a subprogram occurring at the top level
+   --  Reset the Scope of a subprogram and object declaration
+   --  occurring at the top level
 
when N_Subprogram_Body =>
   Id := Defining_Entity (Stat);
@@ -3715,12 +3717,33 @@ package body Exp_Ch7 is
   Set_Block_Elab_Proc;
   Set_Scope (Id, Block_Elab_Proc);
 
+   when N_Object_Declaration
+ | N_Object_Renaming_Declaration =>
+  Id := Defining_Entity (Stat);
+  if No (Block_Elab_Proc) then
+ Append_Elmt (Id, Maybe_Reset_Scopes_For_Decl);
+  else
+ Set_Scope (Id, Block_Elab_Proc);
+  end if;
+
when others =>
   null;
 end case;
 
 Next (Stat);
  end loop;
+
+ --  If we are creating an Elab procedure, move all the gathered
+ --  declarations in its scope.
+
+ if Present (Block_Elab_Proc) then
+while not Is_Empty_Elmt_List (Maybe_Reset_Scopes_For_Decl) loop
+   Set_Scope
+ (Elists.Node
+   (Last_Elmt (Maybe_Reset_Scopes_For_Decl)), Block_Elab_Proc);
+   Remove_Last_Elmt (Maybe_Reset_Scopes_For_Decl);
+end loop;
+ end if;
   end Reset_Scopes_To_Block_Elab_Proc;
 
   --  Local variables


[gcc r15-568] ada: Redundant validity checks

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:584ade0b82339d95463bc91c9fdd77579b16426a

commit r15-568-g584ade0b82339d95463bc91c9fdd77579b16426a
Author: Steve Baird 
Date:   Tue Feb 27 12:11:47 2024 -0800

ada: Redundant validity checks

In some cases with validity checking enabled via the -gnatVa option,
the compiler generates validity checks that can (obviously) never fail.
These include validity checks for (some) static expressions, and consecutive
identical checks generated for a single read of an object.

gcc/ada/

* checks.adb (Expr_Known_Valid): Return True for a static 
expression.
* exp_util.adb (Adjust_Condition): No validity check needed for a
condition if it is an expression for which a validity check has
already been generated.

Diff:
---
 gcc/ada/checks.adb   | 3 +++
 gcc/ada/exp_util.adb | 5 +
 2 files changed, 8 insertions(+)

diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 6af392eeda8a..bada3dffcbfc 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -6839,6 +6839,9 @@ package body Checks is
   then
  return True;
 
+  elsif Is_Static_Expression (Expr) then
+ return True;
+
   --  If the expression is the value of an object that is known to be
   --  valid, then clearly the expression value itself is valid.
 
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 057cf3ebc480..b71f7739481d 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -416,6 +416,11 @@ package body Exp_Util is
  if Validity_Checks_On
and then
  (Validity_Check_Tests or else Is_Hardbool_Type (T))
+
+   --  no check needed here if validity has already been checked
+   and then not
+ (Validity_Check_Operands and then
+   (Nkind (N) in N_Op or else Nkind (Parent (N)) in N_Op))
  then
 Ensure_Valid (N);
  end if;


[gcc r15-570] ada: Remove obsolete reference in comment

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:bff532827515b23335e315141e37475a142c6932

commit r15-570-gbff532827515b23335e315141e37475a142c6932
Author: Eric Botcazou 
Date:   Thu Feb 29 15:52:45 2024 +0100

ada: Remove obsolete reference in comment

gcc/ada/

* exp_ch7.adb (Attach_Object_To_Master_Node): Remove reference to a
transient object in comment.

Diff:
---
 gcc/ada/exp_ch7.adb | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index f9738e115f99..993c13c73187 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -798,10 +798,10 @@ package body Exp_Ch7 is
  return;
   end if;
 
-  --  When the transient object is initialized by an aggregate, the
-  --  attachment must occur after the last aggregate assignment takes
-  --  place. Only then is the object considered initialized. Likewise
-  --  if we have a build-in-place call: we must attach only after it.
+  --  When the object is initialized by an aggregate, the attachment must
+  --  occur after the last aggregate assignment takes place; only then is
+  --  the object considered initialized. Likewise if it is initialized by
+  --  a build-in-place call: we must attach only after the call.
 
   if Ekind (Obj_Id) in E_Constant | E_Variable then
  if Present (Last_Aggregate_Assignment (Obj_Id)) then


[gcc r15-567] ada: Exception on Indefinite_Vector aggregate with loop_parameter_specification

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:9ec20f1f84ad19bb8e2020657ee4c851ba5cd7b0

commit r15-567-g9ec20f1f84ad19bb8e2020657ee4c851ba5cd7b0
Author: Gary Dismukes 
Date:   Tue Feb 27 22:05:55 2024 +

ada: Exception on Indefinite_Vector aggregate with 
loop_parameter_specification

Constraint_Error is raised on evaluation of a container aggregate with
a loop_parameter_specification for the type Indefinite_Vector. This
happens due to the Aggregate aspect for type Indefinite_Vector specifying
the Empty_Vector constant for the type's Empty operation rather than
using the type's primitive Empty function. This problem shows up as
a recent regression relative to earlier compilers, evidently due to
recent fixes in the container aggregate area, which uncovered this
issue of the wrong specification in Ada.Containers.Indefinite_Vectors.
The compiler incorrectly initializes the aggregate object using the
Empty_Vector constant rather than invoking the New_Vector function
to allocate the vector object with the appropriate number of elements,
and subsequent calls to Replace_Element fail because the vector object
is empty.

In addition to correcting the Indefinite_Vectors generic package,
checking is added to give an error for an attempt to specify the
Empty operation as a constant rather than a function. (Also note
that another AdaCore package that needs a similar correction is
the VSS.Vector_Strings package.)

gcc/ada/

* libgnat/a-coinve.ads (type Vector): In the Aggregate aspect for
this type, the Empty operation is changed to denote the Empty
function, rather than the Empty_Vector constant.
* exp_aggr.adb (Expand_Container_Aggregate): Remove code for
handling the case where the Empty_Subp denotes a constant object,
which should never happen (and add an assertion that Empty_Subp
must denote a function).
* sem_ch13.adb (Valid_Empty): No longer allow the entity to be an
E_Constant, and require the (optional) parameter of an Empty
function to be of a signed integer type (rather than any integer
type).

Diff:
---
 gcc/ada/exp_aggr.adb | 24 +---
 gcc/ada/libgnat/a-coinve.ads |  2 +-
 gcc/ada/sem_ch13.adb |  5 +
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index f04dba719d92..5d2b334722a2 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -7119,10 +7119,12 @@ package body Exp_Aggr is
  Append (Init_Stat, Aggr_Code);
 
   --  The container will grow dynamically. Create a declaration for
-  --  the object, and initialize it either from a call to the Empty
-  --  function, or from the Empty constant.
+  --  the object, and initialize it from a call to the parameterless
+  --  Empty function.
 
   else
+ pragma Assert (Ekind (Entity (Empty_Subp)) = E_Function);
+
  Decl :=
Make_Object_Declaration (Loc,
  Defining_Identifier => Temp,
@@ -7130,20 +7132,12 @@ package body Exp_Aggr is
 
  Insert_Action (N, Decl);
 
- --  The Empty entity is either a parameterless function, or
- --  a constant.
-
- if Ekind (Entity (Empty_Subp)) = E_Function then
-Init_Stat := Make_Assignment_Statement (Loc,
-  Name => New_Occurrence_Of (Temp, Loc),
-  Expression => Make_Function_Call (Loc,
-Name => New_Occurrence_Of (Entity (Empty_Subp), Loc)));
+ --  The Empty entity is a parameterless function
 
- else
-Init_Stat := Make_Assignment_Statement (Loc,
-  Name => New_Occurrence_Of (Temp, Loc),
-  Expression => New_Occurrence_Of (Entity (Empty_Subp), Loc));
- end if;
+ Init_Stat := Make_Assignment_Statement (Loc,
+   Name => New_Occurrence_Of (Temp, Loc),
+   Expression => Make_Function_Call (Loc,
+ Name => New_Occurrence_Of (Entity (Empty_Subp), Loc)));
 
  Append (Init_Stat, Aggr_Code);
   end if;
diff --git a/gcc/ada/libgnat/a-coinve.ads b/gcc/ada/libgnat/a-coinve.ads
index 138ec3641c3f..c51ec8aa06dc 100644
--- a/gcc/ada/libgnat/a-coinve.ads
+++ b/gcc/ada/libgnat/a-coinve.ads
@@ -63,7 +63,7 @@ is
  Variable_Indexing => Reference,
  Default_Iterator  => Iterate,
  Iterator_Element  => Element_Type,
- Aggregate => (Empty  => Empty_Vector,
+ Aggregate => (Empty  => Empty,
Add_Unnamed=> Append,
New_Indexed=> New_Vector,
Assign_Indexed => Replace_Element);
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 00392ae88ebe..13bf93ca5489 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -16527,13 +16527,10 @@ 

[gcc r15-565] ada: Fix reference to RM clause in comment

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:33ae453d6836d94f8bcf28f414ce1b4e2e8b9111

commit r15-565-g33ae453d6836d94f8bcf28f414ce1b4e2e8b9111
Author: Ronan Desplanques 
Date:   Tue Feb 27 16:00:10 2024 +0100

ada: Fix reference to RM clause in comment

gcc/ada/

* sem_util.ads (Check_Function_Writable_Actuals): Fix comment.

Diff:
---
 gcc/ada/sem_util.ads | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index 527b1075c3fd..99c60ddf708c 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -373,7 +373,7 @@ package Sem_Util is
--  call C2 (not including the construct N itself), there is no other name
--  anywhere within a direct constituent of the construct C other than
--  the one containing C2, that is known to refer to the same object (RM
-   --  6.4.1(6.17/3)).
+   --  6.4.1(6.18-6.19)).
 
procedure Check_Implicit_Dereference (N : Node_Id; Typ : Entity_Id);
--  AI05-139-2: Accessors and iterators for containers. This procedure


[gcc r15-561] ada: Ignore ghost nodes in call graph information for dispatching calls

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:c485a154ae0cfa1a63c79a1f3b82d6f2d4a107b5

commit r15-561-gc485a154ae0cfa1a63c79a1f3b82d6f2d4a107b5
Author: Piotr Trojanek 
Date:   Mon Feb 26 09:32:20 2024 +0100

ada: Ignore ghost nodes in call graph information for dispatching calls

When emitting call graph information, we already skipped calls to
ignored ghost entities, but this code was causing crashes (in production
builds) and assertion failures (in development builds), because the
ignored ghost entities are not fully decorated, e.g. when they come from
instances of generic units with default subprograms.

With this patch we skip call graph information for ignored ghost
entities when they are registered, both as explicit calls and as
tagged types that will come with internally generated dispatching
subprograms.

gcc/ada/

* exp_cg.adb (Generate_CG_Output): Remove code for ignored ghost
entities that applied to subprogram calls.
(Register_CG_Node): Skip ignored ghost entities, both calls
and tagged types, when they are registered.

Diff:
---
 gcc/ada/exp_cg.adb | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/exp_cg.adb b/gcc/ada/exp_cg.adb
index addf1cae32ac..91a6d40a6fa5 100644
--- a/gcc/ada/exp_cg.adb
+++ b/gcc/ada/exp_cg.adb
@@ -125,14 +125,7 @@ package body Exp_CG is
   for J in Call_Graph_Nodes.First .. Call_Graph_Nodes.Last loop
  N := Call_Graph_Nodes.Table (J);
 
- --  No action needed for subprogram calls removed by the expander
- --  (for example, calls to ignored ghost entities).
-
- if Nkind (N) = N_Null_Statement then
-pragma Assert (Nkind (Original_Node (N)) in N_Subprogram_Call);
-null;
-
- elsif Nkind (N) in N_Subprogram_Call then
+ if Nkind (N) in N_Subprogram_Call then
 Write_Call_Info (N);
 
  else pragma Assert (Nkind (N) = N_Defining_Identifier);
@@ -358,7 +351,13 @@ package body Exp_CG is
 
procedure Register_CG_Node (N : Node_Id) is
begin
-  if Nkind (N) in N_Subprogram_Call then
+  --  Skip ignored ghost calls that will be removed by the expander
+
+  if Is_Ignored_Ghost_Node (N) then
+ null;
+
+  elsif Nkind (N) in N_Subprogram_Call then
+
  if Current_Scope = Main_Unit_Entity
or else Entity_Is_In_Main_Unit (Current_Scope)
  then


[gcc r15-559] ada: Propagate Program_Error from failed finalization of collection

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:8e22376d8e2f2dd97e364aaf81a2b4260847e308

commit r15-559-g8e22376d8e2f2dd97e364aaf81a2b4260847e308
Author: Eric Botcazou 
Date:   Fri Feb 23 21:55:08 2024 +0100

ada: Propagate Program_Error from failed finalization of collection

This aligns finalization collections with finalization masters when it comes
to propagating an exception raised by the finalization of a specific object,
by always propagating Program_Error instead of the aforementioned exception.

gcc/ada/

* libgnat/s-finpri.adb (Raise_From_Controlled_Operation): New
declaration of imported procedure moved from...
(Finalize_Master): ...there.
(Finalize): Call Raise_From_Controlled_Operation instead of
Reraise_Occurrence to propagate the exception, if any.

Diff:
---
 gcc/ada/libgnat/s-finpri.adb | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb
index bd70e582de3d..89f5f2952e45 100644
--- a/gcc/ada/libgnat/s-finpri.adb
+++ b/gcc/ada/libgnat/s-finpri.adb
@@ -37,6 +37,10 @@ with System.Soft_Links;use System.Soft_Links;
 
 package body System.Finalization_Primitives is
 
+   procedure Raise_From_Controlled_Operation (X : Exception_Occurrence);
+   pragma Import (Ada, Raise_From_Controlled_Operation,
+  "__gnat_raise_from_controlled_operation");
+
function To_Collection_Node_Ptr is
  new Ada.Unchecked_Conversion (Address, Collection_Node_Ptr);
 
@@ -297,7 +301,7 @@ package body System.Finalization_Primitives is
   --  If one of the finalization actions raised an exception, reraise it
 
   if Finalization_Exception_Raised then
- Reraise_Occurrence (Exc_Occur);
+ Raise_From_Controlled_Operation (Exc_Occur);
   end if;
end Finalize;
 
@@ -306,12 +310,8 @@ package body System.Finalization_Primitives is
-
 
procedure Finalize_Master (Master : in out Finalization_Master) is
-  procedure Raise_From_Controlled_Operation (X : Exception_Occurrence);
-  pragma Import (Ada, Raise_From_Controlled_Operation,
- "__gnat_raise_from_controlled_operation");
-
-  Finalization_Exception_Raised : Boolean := False;
   Exc_Occur : Exception_Occurrence;
+  Finalization_Exception_Raised : Boolean := False;
   Node  : Master_Node_Ptr;
 
begin


[gcc r15-564] ada: Fix missing length checks with case expressions

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:5c9205a4d729e6fe9b8c897f4eb3ccd86dcf1835

commit r15-564-g5c9205a4d729e6fe9b8c897f4eb3ccd86dcf1835
Author: Ronan Desplanques 
Date:   Tue Feb 27 15:46:14 2024 +0100

ada: Fix missing length checks with case expressions

This fixes an issue where length checks were not generated when the
right-hand side of an assigment involved a case expression.

gcc/ada/

* sem_res.adb (Resolve_Case_Expression): Add length check
insertion.
* exp_ch4.adb (Expand_N_Case_Expression): Add handling of nodes
known to raise Constraint_Error.

Diff:
---
 gcc/ada/exp_ch4.adb | 18 ++
 gcc/ada/sem_res.adb |  3 +++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 7a2003691ec5..448cd5c82b61 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -5098,10 +5098,20 @@ package body Exp_Ch4 is
 
 else
if not Is_Copy_Type (Typ) then
-  Alt_Expr :=
-Make_Attribute_Reference (Alt_Loc,
-  Prefix => Relocate_Node (Alt_Expr),
-  Attribute_Name => Name_Unrestricted_Access);
+  --  It's possible that a call to Apply_Length_Check in
+  --  Resolve_Case_Expression rewrote the dependent expression
+  --  into a N_Raise_Constraint_Error. If that's the case, we
+  --  don't create a reference to Unrestricted_Access, but we
+  --  update the type of the N_Raise_Constraint_Error node.
+
+  if Nkind (Alt_Expr) in N_Raise_Constraint_Error then
+ Set_Etype (Alt_Expr, Target_Typ);
+  else
+ Alt_Expr :=
+   Make_Attribute_Reference (Alt_Loc,
+ Prefix => Relocate_Node (Alt_Expr),
+ Attribute_Name => Name_Unrestricted_Access);
+  end if;
end if;
 
LHS := New_Occurrence_Of (Target, Loc);
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 85795ba3a05f..d2eca7c54591 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -7438,6 +7438,9 @@ package body Sem_Res is
  if Is_Scalar_Type (Alt_Typ) and then Alt_Typ /= Typ then
 Rewrite (Alt_Expr, Convert_To (Typ, Alt_Expr));
 Analyze_And_Resolve (Alt_Expr, Typ);
+
+ elsif Is_Array_Type (Typ) then
+Apply_Length_Check (Alt_Expr, Typ);
  end if;
 
  Next (Alt);


[gcc r15-555] ada: Fix comments about Get_Ranged_Checks

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:fa832b4e799e4db4d815ca9a94e331c55dc2f3b3

commit r15-555-gfa832b4e799e4db4d815ca9a94e331c55dc2f3b3
Author: Ronan Desplanques 
Date:   Thu Feb 22 17:29:24 2024 +0100

ada: Fix comments about Get_Ranged_Checks

Checks.Get_Ranged_Checks was onced named Range_Check, and a few
comments referred to it by that name before this commit. To avoid
confusion with Types.Range_Check, this commits fixes those comments.

gcc/ada/

* checks.ads: Fix comments.
* checks.adb: Likewise.

Diff:
---
 gcc/ada/checks.adb | 4 ++--
 gcc/ada/checks.ads | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index c81482a7b059..4e3eb5027069 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -346,7 +346,7 @@ package body Checks is
   Warn_Node  : Node_Id) return Check_Result;
--  Like Apply_Selected_Length_Checks, except it doesn't modify
--  anything, just returns a list of nodes as described in the spec of
-   --  this package for the Range_Check function.
+   --  this package for the Get_Range_Checks function.
--  ??? In fact it does construct the test and insert it into the tree,
--  and insert actions in various ways (calling Insert_Action directly
--  in particular) so we do not call it in GNATprove mode, contrary to
@@ -359,7 +359,7 @@ package body Checks is
   Warn_Node  : Node_Id) return Check_Result;
--  Like Apply_Range_Check, except it does not modify anything, just
--  returns a list of nodes as described in the spec of this package
-   --  for the Range_Check function.
+   --  for the Get_Range_Checks function.
 
--
-- Access_Checks_Suppressed --
diff --git a/gcc/ada/checks.ads b/gcc/ada/checks.ads
index 36b5fa490fe5..010627c3b034 100644
--- a/gcc/ada/checks.ads
+++ b/gcc/ada/checks.ads
@@ -980,7 +980,7 @@ package Checks is
 private
 
type Check_Result is array (Positive range 1 .. 2) of Node_Id;
-   --  There are two cases for the result returned by Range_Check:
+   --  There are two cases for the result returned by Get_Range_Checks:
--
--For the static case the result is one or two nodes that should cause
--a Constraint_Error. Typically these will include Expr itself or the


[gcc r15-563] ada: Fix standalone Windows builds of adaint.c

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:ea648848eac40e07df0b0e1f5762b5d3f3f738c6

commit r15-563-gea648848eac40e07df0b0e1f5762b5d3f3f738c6
Author: Sebastian Poeplau 
Date:   Mon Feb 26 11:03:03 2024 +0100

ada: Fix standalone Windows builds of adaint.c

Define PATH_SEPARATOR and HOST_EXECUTABLE_SUFFIX in standalone MinGW
builds; the definitions normally come from GCC, and the defaults don't
work for native Windows.

gcc/ada/

* adaint.c: New defines for STANDALONE mode.

Diff:
---
 gcc/ada/adaint.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 74aa3c4128e9..f26d69a1a2a0 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -242,6 +242,13 @@ UINT __gnat_current_ccs_encoding;
 #undef DIR_SEPARATOR
 #define DIR_SEPARATOR '\\'
 
+#ifdef STANDALONE
+#undef PATH_SEPARATOR
+#define PATH_SEPARATOR ';'
+#undef HOST_EXECUTABLE_SUFFIX
+#define HOST_EXECUTABLE_SUFFIX ".exe"
+#endif
+
 #else
 #include 
 #include 


[gcc r15-562] ada: Avoid checking parameters of protected procedures

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:c3b570b5d9354a2366c29c4eb8eaa41c1d087e41

commit r15-562-gc3b570b5d9354a2366c29c4eb8eaa41c1d087e41
Author: Viljar Indus 
Date:   Thu Feb 22 14:27:14 2024 +0200

ada: Avoid checking parameters of protected procedures

The compiler triggers warnings on generated protected procedures
if the procedure does not have an explicit spec. Instead check
if the body was created for a protected procedure if the spec
is not present.

gcc/ada/

* sem_ch6.adb (Analyze_Subprogram_Body_Helper):
If the spec is not present for a subprogram body then
check if the body definiton was created for a protected
procedure.

Diff:
---
 gcc/ada/sem_ch6.adb | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 0a8030cb9236..ca40b5479e09 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -4971,8 +4971,11 @@ package body Sem_Ch6 is
  --  Skip the check for subprograms generated for protected subprograms
  --  because it is also done for the protected subprograms themselves.
 
- elsif Present (Spec_Id)
-   and then Present (Protected_Subprogram (Spec_Id))
+ elsif (Present (Spec_Id)
+ and then Present (Protected_Subprogram (Spec_Id)))
+   or else
+ (Acts_As_Spec (N)
+   and then Present (Protected_Subprogram (Body_Id)))
  then
 null;


[gcc r15-554] ada: Minor performance improvement for dynamically-allocated controlled objects

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:8560a0644da71f5d411ef67382a47278085bad70

commit r15-554-g8560a0644da71f5d411ef67382a47278085bad70
Author: Eric Botcazou 
Date:   Thu Feb 22 08:47:42 2024 +0100

ada: Minor performance improvement for dynamically-allocated controlled 
objects

The values returned by Header_Alignment and Header_Size are known at compile
time and powers of two on almost all platforms, so inlining them by means of
an expression function improves the object code generated for alignment and
size calculations involving them.

gcc/ada/

* libgnat/s-finpri.ads: Add use type clause for Storage_Offset.
(Header_Alignment): Turn into an expression function.
(Header_Size): Likewise.
* libgnat/s-finpri.adb: Remove use type clause for Storage_Offset.
(Header_Alignment): Delete.
(Header_Size): Likewise.

Diff:
---
 gcc/ada/libgnat/s-finpri.adb | 20 
 gcc/ada/libgnat/s-finpri.ads |  8 ++--
 2 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb
index 5bd8eeaea221..bd70e582de3d 100644
--- a/gcc/ada/libgnat/s-finpri.adb
+++ b/gcc/ada/libgnat/s-finpri.adb
@@ -37,8 +37,6 @@ with System.Soft_Links;use System.Soft_Links;
 
 package body System.Finalization_Primitives is
 
-   use type System.Storage_Elements.Storage_Offset;
-
function To_Collection_Node_Ptr is
  new Ada.Unchecked_Conversion (Address, Collection_Node_Ptr);
 
@@ -389,24 +387,6 @@ package body System.Finalization_Primitives is
   end if;
end Finalize_Object;
 
-   --
-   -- Header_Alignment --
-   --
-
-   function Header_Alignment return System.Storage_Elements.Storage_Count is
-   begin
-  return Collection_Node'Alignment;
-   end Header_Alignment;
-
-   -
-   -- Header_Size --
-   -
-
-   function Header_Size return System.Storage_Elements.Storage_Count is
-   begin
-  return Collection_Node'Object_Size / Storage_Unit;
-   end Header_Size;
-

-- Initialize --

diff --git a/gcc/ada/libgnat/s-finpri.ads b/gcc/ada/libgnat/s-finpri.ads
index 468aa5849588..b0b662ca39c5 100644
--- a/gcc/ada/libgnat/s-finpri.ads
+++ b/gcc/ada/libgnat/s-finpri.ads
@@ -39,6 +39,8 @@ with System.Storage_Elements;
 
 package System.Finalization_Primitives with Preelaborate is
 
+   use type System.Storage_Elements.Storage_Offset;
+
type Finalize_Address_Ptr is access procedure (Obj : System.Address);
--  Values of this type denote finalization procedures associated with
--  objects that have controlled parts. For convenience, such objects
@@ -168,10 +170,12 @@ package System.Finalization_Primitives with Preelaborate 
is
--  Calls to the procedure with an object that has already been detached
--  have no effects.
 
-   function Header_Alignment return System.Storage_Elements.Storage_Count;
+   function Header_Alignment return System.Storage_Elements.Storage_Count is
+ (Collection_Node'Alignment);
--  Return the alignment of type Collection_Node as Storage_Count
 
-   function Header_Size return System.Storage_Elements.Storage_Count;
+   function Header_Size return System.Storage_Elements.Storage_Count is
+ (Collection_Node'Object_Size / Storage_Unit);
--  Return the object size of type Collection_Node as Storage_Count
 
 private


[gcc r15-553] ada: Fixup one more pattern of broken scope information

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:513f6b889ab5c9fa88e82506cce7534f0400b1c6

commit r15-553-g513f6b889ab5c9fa88e82506cce7534f0400b1c6
Author: Marc Poulhiès 
Date:   Tue Feb 13 12:20:19 2024 +0100

ada: Fixup one more pattern of broken scope information

When an array's initialization contains a `others =>` clause with an
expression that involves finalization, the resulting scope information
is incorrect and can cause crashes with backend (i.e. gnat-llvm) that
also use unnesting. The observable symptom is a nested object
declaration (created by the compiler) within a loop wrapped in a
procedure created by the unnester that has incoherent scope information:
its Scope field points to the scope of the procedure (1 level too high)
and is contained in the entity chain of some entity nested in the
procedure (correct).

The correct solution would be to fix the scope information when it is
created, but this revealed too large of a task with many interaction
with existing code.

This change adds another pattern to the Fixup_Inner_Scopes procedure to
detect the problematic case and fix the scope, "after the facts".

gcc/ada/

* exp_ch7.adb (Unnest_Loop::Fixup_Inner_Scopes): detect a new
problematic pattern and fixup the scope accordingly.

Diff:
---
 gcc/ada/exp_ch7.adb | 66 +
 1 file changed, 56 insertions(+), 10 deletions(-)

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 25a7c0b2b46d..6d76572f405d 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -8809,8 +8809,11 @@ package body Exp_Ch7 is
 
procedure Unnest_Loop (Loop_Stmt : Node_Id) is
 
-  procedure Fixup_Inner_Scopes (Loop_Stmt : Node_Id);
-  --  The loops created by the compiler for array aggregates can have
+  procedure Fixup_Inner_Scopes (Loop_Or_Block : Node_Id);
+  --  This procedure fixes the scope for 2 identified cases of incorrect
+  --  scope information.
+  --
+  --  1) The loops created by the compiler for array aggregates can have
   --  nested finalization procedure when the type of the array components
   --  needs finalization. It has the following form:
 
@@ -8825,7 +8828,7 @@ package body Exp_Ch7 is
   --obj (J4b) := ...;
 
   --  When the compiler creates the N_Block_Statement, it sets its scope to
-  --  the upper scope (the one containing the loop).
+  --  the outer scope (the one containing the loop).
 
   --  The Unnest_Loop procedure moves the N_Loop_Statement inside a new
   --  procedure and correctly sets the scopes for both the new procedure
@@ -8833,25 +8836,68 @@ package body Exp_Ch7 is
   --  leaves the Tree in an incoherent state (i.e. the inner procedure must
   --  have its enclosing procedure in its scope ancestries).
 
-  --  This procedure fixes the scope links.
+  --  2) The second case happens when an object declaration is created
+  --  within a loop used to initialize the 'others' components of an
+  --  aggregate that is nested within a transient scope. When the transient
+  --  scope is removed, the object scope is set to the outer scope. For
+  --  example:
+
+  --  package pack
+  --   ...
+  -- L98s : for J90s in 2 .. 19 loop
+  --B101s : declare
+  --   R92s : aliased some_type;
+  --   ...
+
+  --  The loop L98s was initially wrapped in a transient scope B72s and
+  --  R92s was nested within it. Then the transient scope is removed and
+  --  the scope of R92s is set to 'pack'. And finally, when the unnester
+  --  moves the loop body in a new procedure, R92s's scope is still left
+  --  unchanged.
+
+  --  This procedure finds the two previous patterns and fixes the scope
+  --  information.
 
   --  Another (better) fix would be to have the block scope set to be the
   --  loop entity earlier (when the block is created or when the loop gets
   --  an actual entity set). But unfortunately this proved harder to
   --  implement ???
 
-  procedure Fixup_Inner_Scopes (Loop_Stmt : Node_Id) is
- Stmt  : Node_Id:= First (Statements (Loop_Stmt));
- Loop_Stmt_Ent : constant Entity_Id := Entity (Identifier (Loop_Stmt));
- Ent_To_Fix: Entity_Id;
+  procedure Fixup_Inner_Scopes (Loop_Or_Block : Node_Id) is
+ Stmt  : Node_Id;
+ Loop_Or_Block_Ent : Entity_Id;
+ Ent_To_Fix: Entity_Id;
+ Decl  : Node_Id := Empty;
   begin
+ pragma Assert (Nkind (Loop_Or_Block) in
+   N_Loop_Statement | N_Block_Statement);
+
+ Loop_Or_Block_Ent := Entity (Identifier (Loop_Or_Block));
+ if Nkind (Loop_Or_Block) = N_Loop_Statement then
+Stmt := First (Statements (Loop_Or_Block));
+ else -- N_Block_Statement

[gcc r15-560] ada: Fix reason code for length check

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:a802cb3c5f530e77dabcb6343d79cb7a24f96ed3

commit r15-560-ga802cb3c5f530e77dabcb6343d79cb7a24f96ed3
Author: Ronan Desplanques 
Date:   Fri Feb 23 13:07:17 2024 +0100

ada: Fix reason code for length check

This patch fixes the reason code used by Apply_Selected_Length_Checks,
which was wrong in some cases when the check could be determined to
always fail at compile time.

gcc/ada/

* checks.adb (Apply_Selected_Length_Checks): Fix reason code.

Diff:
---
 gcc/ada/checks.adb | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 4e3eb5027069..6af392eeda8a 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -322,7 +322,8 @@ package body Checks is
--  that the access value is non-null, since the checks do not
--  not apply to null access values.
 
-   procedure Install_Static_Check (R_Cno : Node_Id; Loc : Source_Ptr);
+   procedure Install_Static_Check
+ (R_Cno : Node_Id; Loc : Source_Ptr; Reason : RT_Exception_Code);
--  Called by Apply_{Length,Range}_Checks to rewrite the tree with the
--  Constraint_Error node.
 
@@ -3001,7 +3002,7 @@ package body Checks is
 Insert_Action (Insert_Node, R_Cno);
 
  else
-Install_Static_Check (R_Cno, Loc);
+Install_Static_Check (R_Cno, Loc, CE_Range_Check_Failed);
  end if;
   end loop;
end Apply_Range_Check;
@@ -3469,7 +3470,7 @@ package body Checks is
 end if;
 
  else
-Install_Static_Check (R_Cno, Loc);
+Install_Static_Check (R_Cno, Loc, CE_Length_Check_Failed);
  end if;
   end loop;
end Apply_Selected_Length_Checks;
@@ -8692,14 +8693,16 @@ package body Checks is
-- Install_Static_Check --
--
 
-   procedure Install_Static_Check (R_Cno : Node_Id; Loc : Source_Ptr) is
+   procedure Install_Static_Check
+ (R_Cno : Node_Id; Loc : Source_Ptr; Reason : RT_Exception_Code)
+   is
   Stat : constant Boolean   := Is_OK_Static_Expression (R_Cno);
   Typ  : constant Entity_Id := Etype (R_Cno);
 
begin
   Rewrite (R_Cno,
 Make_Raise_Constraint_Error (Loc,
-  Reason => CE_Range_Check_Failed));
+  Reason => Reason));
   Set_Analyzed (R_Cno);
   Set_Etype (R_Cno, Typ);
   Set_Raises_Constraint_Error (R_Cno);


[gcc r15-551] ada: Fix latent alignment issue for dynamically-allocated controlled objects

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:48068753771507b4e95f746eaf8b0d0135e6c8ef

commit r15-551-g48068753771507b4e95f746eaf8b0d0135e6c8ef
Author: Eric Botcazou 
Date:   Wed Feb 21 21:48:13 2024 +0100

ada: Fix latent alignment issue for dynamically-allocated controlled objects

Dynamically-allocated controlled objects are attached to a finalization
collection by means of a hidden header placed right before the object,
which means that the size effectively allocated must naturally account
for the size of this header.  But the allocation must also account for
the alignment of this header in order to have it properly aligned.

gcc/ada/

* libgnat/s-finpri.ads (Header_Alignment): New function.
(Header_Size): Adjust description.
(Master_Node): Put Finalize_Address as first component.
(Collection_Node): Likewise.
* libgnat/s-finpri.adb (Header_Alignment): New function.
(Header_Size): Return the object size in storage units.
* libgnat/s-stposu.ads (Adjust_Controlled_Dereference): Replace
collection node with header in description.
* libgnat/s-stposu.adb (Adjust_Controlled_Dereference): Likewise.
(Allocate_Any_Controlled): Likewise.  Pass the maximum of the
specified alignment and that of the header to the allocator.
(Deallocate_Any_Controlled): Likewise to the deallocator.

Diff:
---
 gcc/ada/libgnat/s-finpri.adb | 11 ++-
 gcc/ada/libgnat/s-finpri.ads | 21 +-
 gcc/ada/libgnat/s-stposu.adb | 69 ++--
 gcc/ada/libgnat/s-stposu.ads |  2 +-
 4 files changed, 66 insertions(+), 37 deletions(-)

diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb
index 09f2761a5b93..5bd8eeaea221 100644
--- a/gcc/ada/libgnat/s-finpri.adb
+++ b/gcc/ada/libgnat/s-finpri.adb
@@ -389,13 +389,22 @@ package body System.Finalization_Primitives is
   end if;
end Finalize_Object;
 
+   --
+   -- Header_Alignment --
+   --
+
+   function Header_Alignment return System.Storage_Elements.Storage_Count is
+   begin
+  return Collection_Node'Alignment;
+   end Header_Alignment;
+
-
-- Header_Size --
-
 
function Header_Size return System.Storage_Elements.Storage_Count is
begin
-  return Collection_Node'Size / Storage_Unit;
+  return Collection_Node'Object_Size / Storage_Unit;
end Header_Size;
 

diff --git a/gcc/ada/libgnat/s-finpri.ads b/gcc/ada/libgnat/s-finpri.ads
index 4ba13dadec02..468aa5849588 100644
--- a/gcc/ada/libgnat/s-finpri.ads
+++ b/gcc/ada/libgnat/s-finpri.ads
@@ -168,8 +168,11 @@ package System.Finalization_Primitives with Preelaborate is
--  Calls to the procedure with an object that has already been detached
--  have no effects.
 
+   function Header_Alignment return System.Storage_Elements.Storage_Count;
+   --  Return the alignment of type Collection_Node as Storage_Count
+
function Header_Size return System.Storage_Elements.Storage_Count;
-   --  Return the size of type Collection_Node as Storage_Count
+   --  Return the object size of type Collection_Node as Storage_Count
 
 private
 
@@ -182,11 +185,13 @@ private
 
--  Finalization masters:
 
-   --  Master node type structure
+   --  Master node type structure. Finalize_Address comes first because it is
+   --  an access-to-subprogram and, therefore, might be twice as large and as
+   --  aligned as an access-to-object on some platforms.
 
type Master_Node is record
-  Object_Address   : System.Address   := System.Null_Address;
   Finalize_Address : Finalize_Address_Ptr := null;
+  Object_Address   : System.Address   := System.Null_Address;
   Next : Master_Node_Ptr  := null;
end record;
 
@@ -211,15 +216,17 @@ private
 
--  Finalization collections:
 
-   --  Collection node type structure
+   --  Collection node type structure. Finalize_Address comes first because it
+   --  is an access-to-subprogram and, therefore, might be twice as large and
+   --  as aligned as an access-to-object on some platforms.
 
type Collection_Node is record
-  Enclosing_Collection : Finalization_Collection_Ptr := null;
-  --  A pointer to the collection to which the node is attached
-
   Finalize_Address : Finalize_Address_Ptr := null;
   --  A pointer to the Finalize_Address procedure of the object
 
+  Enclosing_Collection : Finalization_Collection_Ptr := null;
+  --  A pointer to the collection to which the node is attached
+
   Prev : Collection_Node_Ptr := null;
   Next : Collection_Node_Ptr := null;
   --  Collection nodes are managed as a circular doubly-linked list
diff --git a/gcc/ada/libgnat/s-stposu.adb b/gcc/ada/libgnat/s-stposu.adb
index 38dc69f976a1..84535d2a506d 100644
--- a/gcc/ada/libgnat/s-stposu.adb

[gcc r15-558] ada: Improve recovery from illegal occurrence of 'Old in if_expression

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:55d11e8751e070e38f981e308d84dfde23c2af3d

commit r15-558-g55d11e8751e070e38f981e308d84dfde23c2af3d
Author: Piotr Trojanek 
Date:   Thu Feb 22 22:26:01 2024 +0100

ada: Improve recovery from illegal occurrence of 'Old in if_expression

Fix assertion failure in developer builds which happened when the THEN
expression contains an illegal occurrence of 'Old and the type of the
THEN expression is left as Any_Type, but there is no ELSE expression.

gcc/ada/

* sem_ch4.adb (Analyze_If_Expression): Add guard for
if_expression without an ELSE part.

Diff:
---
 gcc/ada/sem_ch4.adb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index b4414a3f7ff9..03364dade9f6 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -2645,7 +2645,7 @@ package body Sem_Ch4 is
  ("\ELSE expression has}!", Else_Expr, Etype (Else_Expr));
 end if;
 
- else
+ elsif Present (Else_Expr) then
 if Is_Overloaded (Else_Expr) then
Error_Msg_N
  ("no interpretation compatible with type of THEN expression",


[gcc r15-557] ada: No need to follow New_Occurrence_Of with Set_Etype

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:f5c78702f9436bfa5a0cf1f87b6004ead79c5892

commit r15-557-gf5c78702f9436bfa5a0cf1f87b6004ead79c5892
Author: Piotr Trojanek 
Date:   Fri Feb 23 13:57:27 2024 +0100

ada: No need to follow New_Occurrence_Of with Set_Etype

Routine New_Occurrence_Of itself sets the Etype of its result; there is
no need to set it explicitly afterwards.

Code cleanup related to fix for attribute 'Old; semantics is unaffected.

gcc/ada/

* exp_ch13.adb (Expand_N_Free_Statement): After analysis, the
new temporary has the type of its Object_Definition and the new
occurrence of this temporary has this type as well; simplify.
* sem_util.adb
(Indirect_Temp_Value): Remove redundant call to Set_Etype;
simplify.
(Is_Access_Type_For_Indirect_Temp): Add missing body header.

Diff:
---
 gcc/ada/exp_ch13.adb |  9 ++---
 gcc/ada/sem_util.adb | 11 +++
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/gcc/ada/exp_ch13.adb b/gcc/ada/exp_ch13.adb
index 2d5ee9b6e803..af8c925586c4 100644
--- a/gcc/ada/exp_ch13.adb
+++ b/gcc/ada/exp_ch13.adb
@@ -358,21 +358,16 @@ package body Exp_Ch13 is
  declare
 Expr_Typ : constant Entity_Id  := Etype (Expr);
 Loc  : constant Source_Ptr := Sloc (N);
-New_Expr : Node_Id;
-Temp_Id  : Entity_Id;
+Temp_Id  : constant Entity_Id  := Make_Temporary (Loc, 'T');
 
  begin
-Temp_Id := Make_Temporary (Loc, 'T');
 Insert_Action (N,
   Make_Object_Declaration (Loc,
 Defining_Identifier => Temp_Id,
 Object_Definition   => New_Occurrence_Of (Expr_Typ, Loc),
 Expression  => Relocate_Node (Expr)));
 
-New_Expr := New_Occurrence_Of (Temp_Id, Loc);
-Set_Etype (New_Expr, Expr_Typ);
-
-Set_Expression (N, New_Expr);
+Set_Expression (N, New_Occurrence_Of (Temp_Id, Loc));
  end;
   end if;
 
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 766cabfc109d..5ebb1319de7e 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -31081,8 +31081,7 @@ package body Sem_Util is
  begin
 if Is_Anonymous_Access_Type (Typ) then
--  No indirection in this case; just evaluate the temp.
-   Result := New_Occurrence_Of (Temp, Loc);
-   Set_Etype (Result, Etype (Temp));
+   return New_Occurrence_Of (Temp, Loc);
 
 else
Result := Make_Explicit_Dereference (Loc,
@@ -31101,11 +31100,15 @@ package body Sem_Util is
 
   Set_Etype (Result, Typ);
end if;
-end if;
 
-return Result;
+   return Result;
+end if;
  end Indirect_Temp_Value;
 
+ --
+ -- Is_Access_Type_For_Indirect_Temp --
+ --
+
  function Is_Access_Type_For_Indirect_Temp
(T : Entity_Id) return Boolean is
  begin


[gcc r15-556] ada: Fix detection of if_expressions that are known on entry

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:7d2a5dbbfed311b9d13e5772dbc86f525adde3e9

commit r15-556-g7d2a5dbbfed311b9d13e5772dbc86f525adde3e9
Author: Piotr Trojanek 
Date:   Thu Feb 22 22:25:16 2024 +0100

ada: Fix detection of if_expressions that are known on entry

Fix a small glitch in routine Is_Known_On_Entry, which returned False
for all if_expressions, regardless whether their conditions or dependent
expressions are known on entry.

gcc/ada/

* sem_util.adb (Is_Known_On_Entry): Check whether condition and
dependent expressions of an if_expression are known on entry.

Diff:
---
 gcc/ada/sem_util.adb | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 68e131db6062..766cabfc109d 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -30784,9 +30784,7 @@ package body Sem_Util is
   return Is_Known_On_Entry (Expression (Expr));
 
when N_If_Expression =>
-  if not All_Exps_Known_On_Entry (Expressions (Expr)) then
- return False;
-  end if;
+  return All_Exps_Known_On_Entry (Expressions (Expr));
 
when N_Case_Expression =>
   if not Is_Known_On_Entry (Expression (Expr)) then


[gcc r15-552] ada: Fix typo in CUDA error message

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:bc35098efbfb14cf17f0f79f5dfcb44fdf0975de

commit r15-552-gbc35098efbfb14cf17f0f79f5dfcb44fdf0975de
Author: Piotr Trojanek 
Date:   Thu Feb 22 00:42:59 2024 +0100

ada: Fix typo in CUDA error message

Fix typo in error message; semantics is unaffected.

gcc/ada/

* gnat_cuda.adb (Remove_CUDA_Device_Entities): Fix typo.

Diff:
---
 gcc/ada/gnat_cuda.adb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ada/gnat_cuda.adb b/gcc/ada/gnat_cuda.adb
index 92576a4b397b..b531c15d3806 100644
--- a/gcc/ada/gnat_cuda.adb
+++ b/gcc/ada/gnat_cuda.adb
@@ -270,7 +270,7 @@ package body GNAT_CUDA is
  and then Present (Corresponding_Stub (Parent (Bod)))
then
   Error_Msg_N
-("CUDA_Device not suported on separate subprograms",
+("CUDA_Device not supported on separate subprograms",
  Corresponding_Stub (Parent (Bod)));
else
   Remove (Bod);


[gcc r15-550] ada: Fix resolving tagged operations in array aggregates

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:b98e256652c336160afa47bf8735eb4aa3529135

commit r15-550-gb98e256652c336160afa47bf8735eb4aa3529135
Author: Viljar Indus 
Date:   Fri Feb 9 12:29:41 2024 +0200

ada: Fix resolving tagged operations in array aggregates

In the Two_Pass_Aggregate_Expansion we were removing
all of the entity links in the Iterator_Specification
to avoid reusing the same Iterator_Definition in both
loops.

However this approach was also breaking the links to
calls with dot notation that had been transformed to
the regular call notation.

In order to circumvent this, explicitly create new
identifier definitions when copying the
Iterator_Specfications for both of the loops.

gcc/ada/

* exp_aggr.adb (Two_Pass_Aggregate_Expansion):
Explicitly create new Defining_Iterators for both
of the loops.

Diff:
---
 gcc/ada/exp_aggr.adb | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index bdaca4aab58b..f04dba719d92 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -5714,6 +5714,7 @@ package body Exp_Aggr is
  Iter : Node_Id;
  New_Comp : Node_Id;
  One_Loop : Node_Id;
+ Iter_Id  : Entity_Id;
 
  Size_Expr_Code : List_Id;
  Insertion_Code : List_Id := New_List;
@@ -5730,6 +5731,7 @@ package body Exp_Aggr is
 
  while Present (Assoc) loop
 Iter := Iterator_Specification (Assoc);
+Iter_Id := Defining_Identifier (Iter);
 Incr := Make_Assignment_Statement (Loc,
   Name => New_Occurrence_Of (Size_Id, Loc),
   Expression =>
@@ -5737,10 +5739,16 @@ package body Exp_Aggr is
  Left_Opnd  => New_Occurrence_Of (Size_Id, Loc),
  Right_Opnd => Make_Integer_Literal (Loc, 1)));
 
+--  Avoid using the same iterator definition in both loops by
+--  creating a new iterator for each loop and mapping it over the
+--  original iterator references.
+
 One_Loop := Make_Implicit_Loop_Statement (N,
   Iteration_Scheme =>
 Make_Iteration_Scheme (Loc,
-  Iterator_Specification => New_Copy_Tree (Iter)),
+  Iterator_Specification =>
+ New_Copy_Tree (Iter,
+Map => New_Elmt_List (Iter_Id, New_Copy (Iter_Id,
 Statements => New_List (Incr));
 
 Append (One_Loop, Size_Expr_Code);
@@ -5837,6 +5845,7 @@ package body Exp_Aggr is
 
  while Present (Assoc) loop
 Iter := Iterator_Specification (Assoc);
+Iter_Id := Defining_Identifier (Iter);
 New_Comp := Make_Assignment_Statement (Loc,
Name =>
  Make_Indexed_Component (Loc,
@@ -5869,10 +5878,16 @@ package body Exp_Aggr is
   Attribute_Name => Name_Last)),
Then_Statements => New_List (Incr));
 
+--  Avoid using the same iterator definition in both loops by
+--  creating a new iterator for each loop and mapping it over the
+--  original iterator references.
+
 One_Loop := Make_Implicit_Loop_Statement (N,
   Iteration_Scheme =>
 Make_Iteration_Scheme (Loc,
-  Iterator_Specification => Copy_Separate_Tree (Iter)),
+  Iterator_Specification =>
+ New_Copy_Tree (Iter,
+Map => New_Elmt_List (Iter_Id, New_Copy (Iter_Id,
 Statements => New_List (New_Comp, Incr));
 
 Append (One_Loop, Insertion_Code);


[gcc r15-549] ada: Fix bogus error on function returning noncontrolling result in private part

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:81a5815a48b0d392de7ece86bdcc23a2d72aa5bd

commit r15-549-g81a5815a48b0d392de7ece86bdcc23a2d72aa5bd
Author: Eric Botcazou 
Date:   Tue Feb 20 22:40:47 2024 +0100

ada: Fix bogus error on function returning noncontrolling result in private 
part

This occurs in the additional case of RM 3.9.3(10) in Ada 2012, that is to
say the access controlling result, because the implementation does not use
the same (correct) conditions as in the original case.

This factors out these conditions and uses them in both cases, as well as
adjusts the wording of the message in the first case.

gcc/ada/

* sem_ch6.adb (Check_Private_Overriding): Implement the second part
of RM 3.9.3(10) consistently in both cases.

Diff:
---
 gcc/ada/sem_ch6.adb | 23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index c0bfe873111d..0a8030cb9236 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -11555,35 +11555,30 @@ package body Sem_Ch6 is
   Incomplete_Or_Partial_View (T);
 
   begin
- if not Overrides_Visible_Function (Partial_View) then
+ if not Overrides_Visible_Function (Partial_View)
+   and then
+ Is_Tagged_Type
+   (if Present (Partial_View) then Partial_View else T)
+ then
 
 --  Here, S is "function ... return T;" declared in
 --  the private part, not overriding some visible
 --  operation. That's illegal in the tagged case
 --  (but not if the private type is untagged).
 
-if ((Present (Partial_View)
-  and then Is_Tagged_Type (Partial_View))
-  or else (No (Partial_View)
-and then Is_Tagged_Type (T)))
-  and then T = Base_Type (Etype (S))
-then
+if T = Base_Type (Etype (S)) then
Error_Msg_N
- ("private function with tagged result must"
+ ("private function with controlling result must"
   & " override visible-part function", S);
Error_Msg_N
  ("\move subprogram to the visible part"
   & " (RM 3.9.3(10))", S);
 
 --  Ada 2012 (AI05-0073): Extend this check to the case
---  of a function whose result subtype is defined by an
---  access_definition designating specific tagged type.
+--  of a function with access result type.
 
 elsif Ekind (Etype (S)) = E_Anonymous_Access_Type
-  and then Is_Tagged_Type (Designated_Type (Etype (S)))
-  and then
-not Is_Class_Wide_Type
-  (Designated_Type (Etype (S)))
+  and then T = Base_Type (Designated_Type (Etype (S)))
   and then Ada_Version >= Ada_2012
 then
Error_Msg_N


[gcc r15-548] ada: Fix casing of CUDA in error messages

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:7c487eb8eccaad7c4ce9e4920fe9eaa5a9fab0bf

commit r15-548-g7c487eb8eccaad7c4ce9e4920fe9eaa5a9fab0bf
Author: Piotr Trojanek 
Date:   Wed Feb 21 12:14:48 2024 +0100

ada: Fix casing of CUDA in error messages

Error messages now capitalize CUDA.

gcc/ada/

* erroutc.adb (Set_Msg_Insertion_Reserved_Word): Fix casing for
CUDA appearing in error message strings.
(Set_Msg_Str): Likewise for CUDA being a part of a Name_Id.

Diff:
---
 gcc/ada/erroutc.adb | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index be200e0016e3..cef04d5daf29 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -1475,12 +1475,17 @@ package body Erroutc is
   if Name_Len = 2 and then Name_Buffer (1 .. 2) = "RM" then
  Set_Msg_Name_Buffer;
 
+  --  We make a similar exception for CUDA
+
+  elsif Name_Len = 4 and then Name_Buffer (1 .. 4) = "CUDA" then
+ Set_Msg_Name_Buffer;
+
   --  We make a similar exception for SPARK
 
   elsif Name_Len = 5 and then Name_Buffer (1 .. 5) = "SPARK" then
  Set_Msg_Name_Buffer;
 
-  --  Neither RM nor SPARK: case appropriately and add surrounding quotes
+  --  Otherwise, case appropriately and add surrounding quotes
 
   else
  Set_Casing (Keyword_Casing (Flag_Source), All_Lower_Case);
@@ -1608,6 +1613,12 @@ package body Erroutc is
   elsif Text = "Cpp_Vtable" then
  Set_Msg_Str ("CPP_Vtable");
 
+  elsif Text = "Cuda_Device" then
+ Set_Msg_Str ("CUDA_Device");
+
+  elsif Text = "Cuda_Global" then
+ Set_Msg_Str ("CUDA_Global");
+
   elsif Text = "Persistent_Bss" then
  Set_Msg_Str ("Persistent_BSS");


[gcc r15-547] ada: Fix crash with -gnatdJ and -gnatw_q

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:f03905788cbe2799a692b1f2435020b26a5a2574

commit r15-547-gf03905788cbe2799a692b1f2435020b26a5a2574
Author: Ronan Desplanques 
Date:   Mon Feb 19 11:17:51 2024 +0100

ada: Fix crash with -gnatdJ and -gnatw_q

This commit makes the emission of -gnatw_q warnings pass node information
so as to handle the enclosing subprogram display of -gnatdJ instead of
crashing.

gcc/ada/

* exp_ch4.adb (Expand_Composite_Equality): Call Error_Msg_N
instead of Error_Msg.

Diff:
---
 gcc/ada/exp_ch4.adb | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 762e75616a7f..7a2003691ec5 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -2340,12 +2340,12 @@ package body Exp_Ch4 is
pragma Assert
  (Is_First_Subtype (Outer_Type)
or else Is_Generic_Actual_Type (Outer_Type));
-   Error_Msg_Node_1 := Outer_Type;
Error_Msg_Node_2 := Comp_Type;
-   Error_Msg
- ("?_q?""="" for type & uses predefined ""="" for }", Loc);
+   Error_Msg_N
+ ("?_q?""="" for type & uses predefined ""="" for }",
+  Outer_Type);
Error_Msg_Sloc := Sloc (Op);
-   Error_Msg ("\?_q?""="" # is ignored here", Loc);
+   Error_Msg_N ("\?_q?""="" # is ignored here", Outer_Type);
 end if;
  end;


[gcc r15-546] ada: Follow up fixes for Put_Image/streaming regressions

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:a58b6be7f38e7a775f92b8aaa8d1c374a6e0c790

commit r15-546-ga58b6be7f38e7a775f92b8aaa8d1c374a6e0c790
Author: Steve Baird 
Date:   Fri Feb 16 17:05:09 2024 -0800

ada: Follow up fixes for Put_Image/streaming regressions

A recent change to reduce duplication of compiler-generated Put_Image and
streaming subprograms introduced some regressions. The fix for one of them
was incomplete.

gcc/ada/

* exp_attr.adb (Build_And_Insert_Type_Attr_Subp): Further tweaking
of the point where a compiler-generated Put_Image or streaming
subprogram is to be inserted in the tree. If one such subprogram
calls another (as is often the case with, for example, Put_Image
procedures for composite type and for a component type thereof),
then we want to avoid use-before-definition problems that can
result from inserting the caller ahead of the callee.

Diff:
---
 gcc/ada/exp_attr.adb | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index e12e8b4a439a..03bf4cf329c3 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -1954,6 +1954,44 @@ package body Exp_Attr is
 while Present (Ancestor) loop
if Is_List_Member (Ancestor) then
   Insertion_Point := First (List_Containing (Ancestor));
+
+  --  A hazard to avoid here is use-before-definition
+  --  errors that can result when we have two of these
+  --  subprograms where one calls the other (e.g., given
+  --  Put_Image procedures for a composite type and
+  --  for a component type, the former will often call
+  --  the latter). At the time a subprogram is inserted,
+  --  we know that the one and only call to it is
+  --  somewhere in the subtree rooted at Ancestor.
+  --  So that placement constraint is easy to satisfy.
+  --  But if we construct another subprogram later and
+  --  if that second subprogram calls the first one,
+  --  then we need to be careful not to place the
+  --  second one ahead of the first one. That is the goal
+  --  of this loop. This may need to be revised if it turns
+  --  out that other stuff is being inserted on the list,
+  --  so that the loop terminates too early.
+
+  --  On the other hand, it seems like inserting things
+  --  earlier offers more opportunities for sharing.
+  --  If Ancestor occurs in the statement list of a
+  --  subprogram body (ignore the HSS node for now),
+  --  then perhaps we should look for an insertion site
+  --  in the decl list of the subprogram body and only
+  --  look in the statement list if the decl list is empty.
+  --  Similarly if Ancestor occors in the private decls list
+  --  for a package spec that has a non-empty visible
+  --  decls list. No examples where this would result in more
+  --  sharing and less duplication have been observed, so this
+  --  is just speculation.
+
+  while Insertion_Point /= Ancestor
+and then Nkind (Insertion_Point) = N_Subprogram_Body
+and then not Comes_From_Source (Insertion_Point)
+  loop
+ Next (Insertion_Point);
+  end loop;
+
   pragma Assert (Present (Insertion_Point));
end if;
Ancestor := Parent (Ancestor);


[gcc r15-545] ada: Implement per-finalization-collection spinlocks

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:50ae8753fb7d65e810fa60fbd396f6d9e3d9

commit r15-545-g50ae8753fb7d65e810fa60fbd396f6d9e3d9
Author: Eric Botcazou 
Date:   Fri Feb 16 18:55:21 2024 +0100

ada: Implement per-finalization-collection spinlocks

This changes the implementation of finalization collections from using the
global task lock to using per-collection spinlocks.  Spinlocks are a good
fit in this context because they are very cheap and therefore can be taken
with a fine granularity only around the portions of code implementing the
shuffling of pointers required by attachment and detachment actions.

gcc/ada/

* libgnat/s-finpri.ads (Lock_Type): New modular type.
(Collection_Node): Add Enclosing_Collection component.
(Finalization_Collection): Add Lock component.
* libgnat/s-finpri.adb: Add clauses for System.Atomic_Primitives.
(Attach_Object_To_Collection): Lock and unlock the collection.
Save a pointer to the enclosing collection in the node.
(Detach_Object_From_Collection): Lock and unlock the collection.
(Finalize): Likewise.
(Initialize): Initialize the lock.
(Lock_Collection): New procedure.
(Unlock_Collection): Likewise.

Diff:
---
 gcc/ada/libgnat/s-finpri.adb | 79 +++-
 gcc/ada/libgnat/s-finpri.ads | 12 ++-
 2 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb
index 8026b3fb284b..09f2761a5b93 100644
--- a/gcc/ada/libgnat/s-finpri.adb
+++ b/gcc/ada/libgnat/s-finpri.adb
@@ -32,7 +32,8 @@
 with Ada.Exceptions;   use Ada.Exceptions;
 with Ada.Unchecked_Conversion;
 
-with System.Soft_Links; use System.Soft_Links;
+with System.Atomic_Primitives; use System.Atomic_Primitives;
+with System.Soft_Links;use System.Soft_Links;
 
 package body System.Finalization_Primitives is
 
@@ -42,7 +43,21 @@ package body System.Finalization_Primitives is
  new Ada.Unchecked_Conversion (Address, Collection_Node_Ptr);
 
procedure Detach_Node_From_Collection (Node : not null Collection_Node_Ptr);
-   --  Removes a collection node from its associated finalization collection
+   --  Remove a collection node from its associated finalization collection.
+   --  Calls to the procedure with a Node that has already been detached have
+   --  no effects.
+
+   procedure Lock_Collection (Collection : in out Finalization_Collection);
+   --  Lock the finalization collection. Upon return, the caller owns the lock
+   --  to the collection and no other call with the same actual parameter will
+   --  return until a corresponding call to Unlock_Collection has been made by
+   --  the caller. This means that it is not possible to call Lock_Collection
+   --  more than once on a collection without a call to Unlock_Collection in
+   --  between.
+
+   procedure Unlock_Collection (Collection : in out Finalization_Collection);
+   --  Unlock the finalization collection, i.e. relinquish ownership of the
+   --  lock to the collection.
 
---
-- Add_Offset_To_Address --
@@ -69,7 +84,7 @@ package body System.Finalization_Primitives is
To_Collection_Node_Ptr (Object_Address - Header_Size);
 
begin
-  Lock_Task.all;
+  Lock_Collection (Collection);
 
   --  Do not allow the attachment of controlled objects while the
   --  associated collection is being finalized.
@@ -89,22 +104,23 @@ package body System.Finalization_Primitives is
   pragma Assert
 (Finalize_Address /= null, "primitive Finalize_Address not available");
 
-  Node.Finalize_Address := Finalize_Address;
-  Node.Prev := Collection.Head'Unchecked_Access;
-  Node.Next := Collection.Head.Next;
+  Node.Enclosing_Collection := Collection'Unrestricted_Access;
+  Node.Finalize_Address := Finalize_Address;
+  Node.Prev := Collection.Head'Unchecked_Access;
+  Node.Next := Collection.Head.Next;
 
   Collection.Head.Next.Prev := Node;
   Collection.Head.Next  := Node;
 
-  Unlock_Task.all;
+  Unlock_Collection (Collection);
 
exception
   when others =>
 
- --  Unlock the task in case the attachment failed and reraise the
- --  exception.
+ --  Unlock the collection in case the attachment failed and reraise
+ --  the exception.
 
- Unlock_Task.all;
+ Unlock_Collection (Collection);
  raise;
end Attach_Object_To_Collection;
 
@@ -180,11 +196,11 @@ package body System.Finalization_Primitives is
To_Collection_Node_Ptr (Object_Address - Header_Size);
 
begin
-  Lock_Task.all;
+  Lock_Collection (Node.Enclosing_Collection.all);
 
   Detach_Node_From_Collection (Node);
 
-  Unlock_Task.all;
+  

[gcc r15-544] ada: Formal_Derived_Type'Size is not static

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:91c6302c8d641990f8977bf8eb5a40370da6efa9

commit r15-544-g91c6302c8d641990f8977bf8eb5a40370da6efa9
Author: Steve Baird 
Date:   Thu Feb 15 14:49:18 2024 -0800

ada: Formal_Derived_Type'Size is not static

In deciding whether a Size attribute reference is static, the compiler could
get confused about whether an implicitly-declared subtype of a generic 
formal
type is itself a generic formal type, possibly resulting in an assertion
failure and then a bugbox.

gcc/ada/

* sem_attr.adb (Eval_Attribute): Expand existing checks for
generic formal types for which Is_Generic_Type returns False. In
that case, mark the attribute reference as nonstatic.

Diff:
---
 gcc/ada/sem_attr.adb | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 65442d45a85f..2fa7d7d25d22 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -8685,10 +8685,20 @@ package body Sem_Attr is
   --  If the root type or base type is generic, then we cannot fold. This
   --  test is needed because subtypes of generic types are not always
   --  marked as being generic themselves (which seems odd???)
+  --
+  --  Should this situation be addressed instead by either
+  -- a) setting Is_Generic_Type in more cases
+  --  or b) replacing preceding calls to Is_Generic_Type with calls to
+  --Sem_Util.Some_New_Function
+  --  so that we wouldn't have to deal with these cases here ???
 
   if Is_Generic_Type (P_Root_Type)
 or else Is_Generic_Type (P_Base_Type)
+or else (Present (Associated_Node_For_Itype (P_Base_Type))
+  and then Is_Generic_Type (Defining_Identifier
+ (Associated_Node_For_Itype (P_Base_Type
   then
+ Set_Is_Static_Expression (N, False);
  return;
   end if;


[gcc r15-543] ada: Fix bug in maintaining dimension info

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:e730d52a9459d1112e58c7286aab0e358fac

commit r15-543-ge730d52a9459d1112e58c7286aab0e358fac
Author: Steve Baird 
Date:   Thu Feb 15 15:13:12 2024 -0800

ada: Fix bug in maintaining dimension info

Copying a node does not automatically propagate its associated dimension
information (if any). This must be done explicitly.

gcc/ada/

* sem_util.adb (Copy_Node_With_Replacement): Add call to
Copy_Dimensions so that any dimension information associated with
the copied node is also associated with the resulting copy.

Diff:
---
 gcc/ada/sem_util.adb | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 1785931530f8..68e131db6062 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -53,6 +53,7 @@ with Sem_Cat;use Sem_Cat;
 with Sem_Ch6;use Sem_Ch6;
 with Sem_Ch8;use Sem_Ch8;
 with Sem_Ch13;   use Sem_Ch13;
+with Sem_Dim;use Sem_Dim;
 with Sem_Disp;   use Sem_Disp;
 with Sem_Elab;   use Sem_Elab;
 with Sem_Eval;   use Sem_Eval;
@@ -23447,6 +23448,8 @@ package body Sem_Util is
   Set_Chars (Result, Chars (Entity (Result)));
end if;
 end if;
+
+Copy_Dimensions (From => N, To => Result);
  end if;
 
  return Result;


[gcc r15-542] ada: Remove Aspect_Specifications field from N_Procedure_Specification

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:8b73cb99bbd02db85d213c7120dbaa366c360e45

commit r15-542-g8b73cb99bbd02db85d213c7120dbaa366c360e45
Author: Piotr Trojanek 
Date:   Fri Feb 16 15:10:06 2024 +0100

ada: Remove Aspect_Specifications field from N_Procedure_Specification

Sync Has_Aspect_Specifications_Flag with the actual flags in the AST.
Code cleanup; behavior is unaffected.

gcc/ada/

* gen_il-gen-gen_nodes.adb (N_Procedure_Specification): Remove
Aspect_Specifications field.

Diff:
---
 gcc/ada/gen_il-gen-gen_nodes.adb | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
index f3dc215673a4..a7021dc49bb8 100644
--- a/gcc/ada/gen_il-gen-gen_nodes.adb
+++ b/gcc/ada/gen_il-gen-gen_nodes.adb
@@ -736,7 +736,6 @@ begin -- Gen_IL.Gen.Gen_Nodes
 Sy (Null_Present, Flag),
 Sy (Must_Override, Flag),
 Sy (Must_Not_Override, Flag),
-Sy (Aspect_Specifications, List_Id, Default_No_List),
 Sm (Null_Statement, Node_Id)));
 
Ab (N_Access_To_Subprogram_Definition, Node_Kind);


[gcc r15-541] ada: Reuse existing expression when rewriting aspects to pragmas

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:06078187797f077f0548c55ac8cb8eca4094f1c3

commit r15-541-g06078187797f077f0548c55ac8cb8eca4094f1c3
Author: Piotr Trojanek 
Date:   Wed Feb 14 18:24:03 2024 +0100

ada: Reuse existing expression when rewriting aspects to pragmas

Code cleanup; semantics is unaffected.

gcc/ada/

* sem_ch13.adb (Analyze_Aspect_Specification): Consistently
reuse existing constant where possible.

Diff:
---
 gcc/ada/sem_ch13.adb | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index ce9f15c1491a..00392ae88ebe 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -1838,7 +1838,7 @@ package body Sem_Ch13 is
Make_Pragma_Argument_Association (Loc,
  Expression => Conv),
Make_Pragma_Argument_Association (Loc,
- Expression => New_Occurrence_Of (E, Loc;
+ Expression => Ent)));
 
   Decorate (Aspect, Aitem);
   Insert_Pragma (Aitem);
@@ -3099,7 +3099,7 @@ package body Sem_Ch13 is
   Aitem := Make_Aitem_Pragma
 (Pragma_Argument_Associations => New_List (
Make_Pragma_Argument_Association (Loc,
- Expression => New_Occurrence_Of (E, Loc)),
+ Expression => Ent),
Make_Pragma_Argument_Association (Sloc (Expr),
  Expression => Relocate_Node (Expr))),
  Pragma_Name  => Name_Linker_Section);
@@ -3120,7 +3120,7 @@ package body Sem_Ch13 is
   Aitem := Make_Aitem_Pragma
 (Pragma_Argument_Associations => New_List (
Make_Pragma_Argument_Association (Loc,
- Expression => New_Occurrence_Of (E, Loc)),
+ Expression => Ent),
Make_Pragma_Argument_Association (Sloc (Expr),
  Expression => Relocate_Node (Expr))),
  Pragma_Name  => Name_Implemented);
@@ -3439,7 +3439,7 @@ package body Sem_Ch13 is
Make_Pragma_Argument_Association (Loc,
  Expression => Relocate_Node (Expr)),
Make_Pragma_Argument_Association (Sloc (Expr),
- Expression => New_Occurrence_Of (E, Loc))),
+ Expression => Ent)),
  Pragma_Name  => Nam);
 
   Delay_Required := False;
@@ -3452,7 +3452,7 @@ package body Sem_Ch13 is
Make_Pragma_Argument_Association (Sloc (Expr),
  Expression => Relocate_Node (Expr)),
Make_Pragma_Argument_Association (Loc,
- Expression => New_Occurrence_Of (E, Loc))),
+ Expression => Ent)),
  Pragma_Name  => Name_Warnings);
 
   Decorate (Aspect, Aitem);


[gcc r15-540] ada: Cleanup reporting locations for Ada 2022 and GNAT extension aspects

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:492f896e3a224a09c5f693249dc302dda435fae7

commit r15-540-g492f896e3a224a09c5f693249dc302dda435fae7
Author: Piotr Trojanek 
Date:   Wed Feb 14 18:06:36 2024 +0100

ada: Cleanup reporting locations for Ada 2022 and GNAT extension aspects

Code cleanup; semantics is unaffected.

gcc/ada/

* sem_ch13.adb (Analyze_Aspect_Specification): Consistently
reuse existing constant where possible.

Diff:
---
 gcc/ada/sem_ch13.adb | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 8bc8e84ceb4a..ce9f15c1491a 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -2417,7 +2417,7 @@ package body Sem_Ch13 is
 
 begin
if Ada_Version < Ada_2022 then
-  Error_Msg_Ada_2022_Feature ("aspect %", Sloc (Aspect));
+  Error_Msg_Ada_2022_Feature ("aspect %", Loc);
   return;
end if;
 
@@ -2442,7 +2442,7 @@ package body Sem_Ch13 is
 
   elsif Is_Imported_Intrinsic then
  Error_Msg_GNAT_Extension
-   ("aspect % on intrinsic function", Sloc (Aspect),
+   ("aspect % on intrinsic function", Loc,
 Is_Core_Extension => True);
 
   else
@@ -4133,7 +4133,7 @@ package body Sem_Ch13 is
 
when Aspect_Designated_Storage_Model =>
   if not All_Extensions_Allowed then
- Error_Msg_GNAT_Extension ("aspect %", Sloc (Aspect));
+ Error_Msg_GNAT_Extension ("aspect %", Loc);
 
   elsif not Is_Type (E)
 or else Ekind (E) /= E_Access_Type
@@ -4148,7 +4148,7 @@ package body Sem_Ch13 is
 
when Aspect_Storage_Model_Type =>
   if not All_Extensions_Allowed then
- Error_Msg_GNAT_Extension ("aspect %", Sloc (Aspect));
+ Error_Msg_GNAT_Extension ("aspect %", Loc);
 
   elsif not Is_Type (E)
 or else not Is_Immutably_Limited_Type (E)
@@ -4479,7 +4479,7 @@ package body Sem_Ch13 is
   --  Ada 2022 (AI12-0363): Full_Access_Only
 
   elsif A_Id = Aspect_Full_Access_Only then
- Error_Msg_Ada_2022_Feature ("aspect %", Sloc (Aspect));
+ Error_Msg_Ada_2022_Feature ("aspect %", Loc);
 
   --  Ada 2022 (AI12-0075): static expression functions


[gcc r15-538] ada: Fix ordering of code for pragma Preelaborable_Initialization

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:61751ee563104aa87a66ac712e97ed80cf52eec2

commit r15-538-g61751ee563104aa87a66ac712e97ed80cf52eec2
Author: Piotr Trojanek 
Date:   Fri Jan 26 18:11:36 2024 +0100

ada: Fix ordering of code for pragma Preelaborable_Initialization

Code cleanup.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Move case alternative to match
to alphabetic order.

Diff:
---
 gcc/ada/sem_prag.adb | 160 +--
 1 file changed, 80 insertions(+), 80 deletions(-)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 105cc73eba36..2fc46ab0cd24 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -21889,86 +21889,6 @@ package body Sem_Prag is
Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
 end if;
 
- --
- -- Preelaborable_Initialization --
- --
-
- --  pragma Preelaborable_Initialization (DIRECT_NAME);
-
- when Pragma_Preelaborable_Initialization => Preelab_Init : declare
-Ent : Entity_Id;
-
- begin
-Ada_2005_Pragma;
-Check_Arg_Count (1);
-Check_No_Identifiers;
-Check_Arg_Is_Identifier (Arg1);
-Check_Arg_Is_Local_Name (Arg1);
-Check_First_Subtype (Arg1);
-Ent := Entity (Get_Pragma_Arg (Arg1));
-
---  A pragma that applies to a Ghost entity becomes Ghost for the
---  purposes of legality checks and removal of ignored Ghost code.
-
-Mark_Ghost_Pragma (N, Ent);
-
---  The pragma may come from an aspect on a private declaration,
---  even if the freeze point at which this is analyzed in the
---  private part after the full view.
-
-if Has_Private_Declaration (Ent)
-  and then From_Aspect_Specification (N)
-then
-   null;
-
---  Check appropriate type argument
-
-elsif Is_Private_Type (Ent)
-  or else Is_Protected_Type (Ent)
-  or else (Is_Generic_Type (Ent) and then Is_Derived_Type (Ent))
-
-  --  AI05-0028: The pragma applies to all composite types. Note
-  --  that we apply this binding interpretation to earlier versions
-  --  of Ada, so there is no Ada 2012 guard. Seems a reasonable
-  --  choice since there are other compilers that do the same.
-
-  or else Is_Composite_Type (Ent)
-then
-   null;
-
-else
-   Error_Pragma_Arg
- ("pragma % can only be applied to private, formal derived, "
-  & "protected, or composite type", Arg1);
-end if;
-
---  Give an error if the pragma is applied to a protected type that
---  does not qualify (due to having entries, or due to components
---  that do not qualify).
-
-if Is_Protected_Type (Ent)
-  and then not Has_Preelaborable_Initialization (Ent)
-then
-   Error_Msg_N
- ("protected type & does not have preelaborable "
-  & "initialization", Ent);
-
---  Otherwise mark the type as definitely having preelaborable
---  initialization.
-
-else
-   Set_Known_To_Have_Preelab_Init (Ent);
-end if;
-
-if Has_Pragma_Preelab_Init (Ent)
-  and then Warn_On_Redundant_Constructs
-then
-   Error_Pragma ("?r?duplicate pragma%!");
-else
-   Set_Has_Pragma_Preelab_Init (Ent);
-end if;
- end Preelab_Init;
-
  
  -- Persistent_BSS --
  
@@ -22057,6 +21977,86 @@ package body Sem_Prag is
 end if;
  end Persistent_BSS;
 
+ --
+ -- Preelaborable_Initialization --
+ --
+
+ --  pragma Preelaborable_Initialization (DIRECT_NAME);
+
+ when Pragma_Preelaborable_Initialization => Preelab_Init : declare
+Ent : Entity_Id;
+
+ begin
+Ada_2005_Pragma;
+Check_Arg_Count (1);
+Check_No_Identifiers;
+Check_Arg_Is_Identifier (Arg1);
+Check_Arg_Is_Local_Name (Arg1);
+Check_First_Subtype (Arg1);
+Ent := Entity (Get_Pragma_Arg (Arg1));
+
+--  A pragma that applies to a Ghost entity becomes Ghost for the
+--  purposes of legality checks and removal of ignored Ghost code.
+
+Mark_Ghost_Pragma (N, Ent);
+
+--  The pragma may come from an aspect on a private declaration,
+--  even if the freeze point at which this is analyzed in the
+--  

[gcc r15-539] ada: Fix alphabetic ordering of aspect identifiers

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:1d992c40e77fa61ebdb75d1342b35f58b9b98f12

commit r15-539-g1d992c40e77fa61ebdb75d1342b35f58b9b98f12
Author: Piotr Trojanek 
Date:   Mon Jan 29 13:42:03 2024 +0100

ada: Fix alphabetic ordering of aspect identifiers

Code cleanup.

gcc/ada/

* aspects.ads (Aspect_Id): Fix ordering.

Diff:
---
 gcc/ada/aspects.ads | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads
index eb5ab1a85dd4..ce393d4f6024 100644
--- a/gcc/ada/aspects.ads
+++ b/gcc/ada/aspects.ads
@@ -198,9 +198,9 @@ package Aspects is
   Aspect_Favor_Top_Level,   -- GNAT
   Aspect_Full_Access_Only,
   Aspect_Ghost, -- GNAT
+  Aspect_Import,
   Aspect_Independent,
   Aspect_Independent_Components,
-  Aspect_Import,
   Aspect_Inline,
   Aspect_Inline_Always, -- GNAT
   Aspect_Interrupt_Handler,
@@ -971,6 +971,7 @@ package Aspects is
   Aspect_Shared_Passive   => Always_Delay,
   Aspect_Simple_Storage_Pool  => Always_Delay,
   Aspect_Simple_Storage_Pool_Type => Always_Delay,
+  Aspect_Stable_Properties=> Always_Delay,
   Aspect_Static_Predicate => Always_Delay,
   Aspect_Storage_Model_Type   => Always_Delay,
   Aspect_Storage_Pool => Always_Delay,
@@ -1032,7 +1033,6 @@ package Aspects is
   Aspect_Relaxed_Initialization   => Never_Delay,
   Aspect_Side_Effects => Never_Delay,
   Aspect_SPARK_Mode   => Never_Delay,
-  Aspect_Stable_Properties=> Always_Delay,
   Aspect_Static   => Never_Delay,
   Aspect_Subprogram_Variant   => Never_Delay,
   Aspect_Synchronization  => Never_Delay,


[gcc r15-537] ada: Fix casing in error messages

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:3549a58fa544fe933eca207a9f2442489310aa4c

commit r15-537-g3549a58fa544fe933eca207a9f2442489310aa4c
Author: Piotr Trojanek 
Date:   Fri Feb 16 16:57:10 2024 +0100

ada: Fix casing in error messages

Error messages should not start with a capital letter.

gcc/ada/

* gnat_cuda.adb (Remove_CUDA_Device_Entities): Fix casing
(this primarily fixes a style, because the capitalization will
not be preserved by the error-reporting machinery anyway).
* sem_ch13.adb (Analyze_User_Aspect_Aspect_Specification): Fix
casing in error message.

Diff:
---
 gcc/ada/gnat_cuda.adb | 2 +-
 gcc/ada/sem_ch13.adb  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/gnat_cuda.adb b/gcc/ada/gnat_cuda.adb
index af47b7287901..92576a4b397b 100644
--- a/gcc/ada/gnat_cuda.adb
+++ b/gcc/ada/gnat_cuda.adb
@@ -270,7 +270,7 @@ package body GNAT_CUDA is
  and then Present (Corresponding_Stub (Parent (Bod)))
then
   Error_Msg_N
-("Cuda_Device not suported on separate subprograms",
+("CUDA_Device not suported on separate subprograms",
  Corresponding_Stub (Parent (Bod)));
else
   Remove (Bod);
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index eee2aa09cd5c..8bc8e84ceb4a 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -8754,7 +8754,7 @@ package body Sem_Ch13 is
  Arg : Node_Id;
   begin
  if No (UAD_Pragma) then
-Error_Msg_N ("No definition for user-defined aspect", Id);
+Error_Msg_N ("no definition for user-defined aspect", Id);
 return;
  end if;


[gcc r15-536] ada: Fix docs and comments about pragmas for Boolean-valued aspects

2024-05-16 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:fd3a9ee2b9d622b8482bbb1167dd0e2244d940e9

commit r15-536-gfd3a9ee2b9d622b8482bbb1167dd0e2244d940e9
Author: Piotr Trojanek 
Date:   Mon Jan 29 13:32:16 2024 +0100

ada: Fix docs and comments about pragmas for Boolean-valued aspects

Fix various inconsistencies in documentation and comments of
Boolean-valued aspects.

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst: Fix
documentation.
* sem_prag.adb: Fix comments.
* gnat_rm.texi: Regenerate.

Diff:
---
 .../doc/gnat_rm/implementation_defined_pragmas.rst | 57 --
 gcc/ada/gnat_rm.texi   | 57 --
 gcc/ada/sem_prag.adb   | 48 +-
 3 files changed, 89 insertions(+), 73 deletions(-)

diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst 
b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
index 3426c34ebe8c..7f221e323446 100644
--- a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
+++ b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
@@ -341,7 +341,7 @@ Syntax:
   pragma Always_Terminates [ (boolean_EXPRESSION) ];
 
 For the semantics of this pragma, see the entry for aspect 
``Always_Terminates``
-in the SPARK 2014 Reference Manual, section 7.1.2.
+in the SPARK 2014 Reference Manual, section 6.1.10.
 
 .. _Pragma-Annotate:
 
@@ -2381,7 +2381,7 @@ Syntax:
 
 .. code-block:: ada
 
-  pragma Favor_Top_Level (type_NAME);
+  pragma Favor_Top_Level (type_LOCAL_NAME);
 
 
 The argument of pragma ``Favor_Top_Level`` must be a named access-to-subprogram
@@ -2838,7 +2838,7 @@ Syntax:
 
 .. code-block:: ada
 
-  pragma Independent (Local_NAME);
+  pragma Independent (component_LOCAL_NAME);
 
 
 This pragma is standard in Ada 2012 mode (which also provides an aspect
@@ -3537,6 +3537,11 @@ Pragma Lock_Free
 
 
 Syntax:
+
+.. code-block:: ada
+
+  pragma Lock_Free [ (static_boolean_EXPRESSION) ];
+
 This pragma may be specified for protected types or objects. It specifies that
 the implementation of protected operations must be implemented without locks.
 Compilation fails if the compiler cannot generate lock-free code for the
@@ -3850,7 +3855,7 @@ same name) that establishes the restriction 
``No_Elaboration_Code`` for
 the current unit and any extended main source units (body and subunits).
 It also has the effect of enforcing a transitive application of this
 aspect, so that if any unit is implicitly or explicitly with'ed by the
-current unit, it must also have the No_Elaboration_Code_All aspect set.
+current unit, it must also have the `No_Elaboration_Code_All` aspect set.
 It may be applied to package or subprogram specs or their generic versions.
 
 Pragma No_Heap_Finalization
@@ -4508,7 +4513,7 @@ Syntax:
 
 ::
 
-  pragma Persistent_BSS [(LOCAL_NAME)]
+  pragma Persistent_BSS [(object_LOCAL_NAME)]
 
 
 This pragma allows selected objects to be placed in the ``.persistent_bss``
@@ -6500,12 +6505,12 @@ Syntax:
 
 ::
 
-  pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
+  pragma Suppress_Initialization ([Entity =>] variable_or_subtype_LOCAL_NAME);
 
 
-Here variable_or_subtype_Name is the name introduced by a type declaration
-or subtype declaration or the name of a variable introduced by an
-object declaration.
+Here variable_or_subtype_LOCAL_NAME is the name introduced by a type
+declaration or subtype declaration or the name of a variable introduced by
+an object declaration.
 
 In the case of a type or subtype
 this pragma suppresses any implicit or explicit initialization
@@ -6889,22 +6894,24 @@ Syntax:
 
 
 This configuration pragma defines a new aspect, making it available for
-subsequent use in a User_Aspect aspect specification. The first
-identifier is the name of the new aspect. Any subsequent arguments
-specify the names of other aspects. A subsequent name for which no 
parenthesized
-arguments are given shall denote either a Boolean-valued
-non-representation aspect or an aspect that has been defined by another
-User_Aspect_Definition pragma. A name for which one or more arguments are
-given shall be either Annotate or Local_Restrictions (and the arguments shall
-be appropriate for the named aspect). This pragma, together with the
-User_Aspect aspect, provides a mechanism for
-avoiding textual duplication if some set of aspect specifications is needed
-in multiple places. This is somewhat analogous to how profiles allow avoiding
-duplication of Restrictions pragmas. The visibility rules for an aspect
-defined by a User_Aspect_Definition pragma are the same as for a check name
-introduced by a Check_Name pragma. If multiple
-definitions are visible for some aspect at some point, then the
-definitions must agree. A predefined aspect cannot be redefined.
+subsequent use in a `User_Aspect` aspect specification. The first identifier
+is the name of the new aspect. Any