]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
6 months agoDaily bump.
GCC Administrator [Wed, 8 Jan 2025 00:20:03 +0000 (00:20 +0000)] 
Daily bump.

6 months agoMatch: Update the comments for indicating SAT_* pattern
Pan Li [Thu, 12 Dec 2024 02:56:35 +0000 (10:56 +0800)] 
Match: Update the comments for indicating SAT_* pattern

Given the SAT_* patterns are grouped for each alu and signed or not,
add leading comments to indicate the beginning of the pattern.

gcc/ChangeLog:

* match.pd: Update comments for sat_* pattern.

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agoMatch: Refactor the signed SAT_* match for saturated value [NFC]
Pan Li [Thu, 12 Dec 2024 02:48:08 +0000 (10:48 +0800)] 
Match: Refactor the signed SAT_* match for saturated value [NFC]

This patch would like to refactor the all signed SAT_* patterns for
the saturated value.  Aka, overflow to INT_MAX when > 0 and downflow
to INT_MIN when < 0.  Thus, we can remove sorts of duplicated expression
in different patterns.

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

gcc/ChangeLog:

* match.pd: Extract saturated value match for signed SAT_*.

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agoMatch: Refactor the signed SAT_TRUNC match patterns [NFC]
Pan Li [Wed, 11 Dec 2024 11:37:06 +0000 (19:37 +0800)] 
Match: Refactor the signed SAT_TRUNC match patterns [NFC]

This patch would like to refactor the all signed SAT_TRUNC patterns,
aka:
* Extract type check outside.
* Re-arrange the related match pattern forms together.

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

gcc/ChangeLog:

* match.pd: Refactor sorts of signed SAT_TRUNC match patterns

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agoMatch: Refactor the signed SAT_SUB match patterns [NFC]
Pan Li [Wed, 11 Dec 2024 11:09:08 +0000 (19:09 +0800)] 
Match: Refactor the signed SAT_SUB match patterns [NFC]

This patch would like to refactor the all signed SAT_ADD patterns,
aka:
* Extract type check outside.
* Re-arrange the related match pattern forms together.

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

gcc/ChangeLog:

* match.pd: Refactor sorts of signed SAT_SUB match patterns.

Signed-off-by: Pan Li <pan2.li@intel.com>
6 months agoRISC-V: vector absolute difference expander [PR117722]
Vineet Gupta [Tue, 7 Jan 2025 22:28:25 +0000 (14:28 -0800)] 
RISC-V: vector absolute difference expander [PR117722]

This improves codegen for x264 sum of absolute difference routines.
The insn count is same, but we avoid double widening ops and ensuing
whole register moves.

Also for more general applicability, we chose to implement abs diff
vs. the sum of abs diff variant.

Suggested-by: Robin Dapp <rdapp@ventanamicro.com>
Co-authored-by: Pan Li <pan2.li@intel.com>
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
PR target/117722

gcc/ChangeLog:
* config/riscv/autovec.md: Add uabd expander.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr117722.c: New test.

6 months ago[PATCH] libgcc/m68k: More fixes for soft float
Keith Packard [Tue, 7 Jan 2025 21:54:11 +0000 (14:54 -0700)] 
[PATCH] libgcc/m68k: More fixes for soft float

Fix __extenddfxf2:

  * Remove bogus denorm handling block which would never execute --
    the converted exp value is always positive as EXCESSX > EXCESSD.

  * Compute the whole significand in dl instead of doing part of it in
    ldl.

    * Mask off exponent from dl.l.upper so the denorm shift test
      works.

    * Insert the hidden one bit into dl.l.upper as needed.

Fix __truncxfdf2 denorm handling. All that is required is to shift the
significand right by the correct amount; it already has all of the
necessary bits set including the explicit one. Compute the shift
amount, then perform the wide shift across both elements of the
significand.

Fix __fixxfsi:

  * The value  was off by a factor of two as the significand contains
    32 bits, not 31 so we need to shift by one more than the equivalent
    code in __fixdfsi.

  * Simplify the code having realized that the lower 32 bits of the
    significand can never appear in the results.

Return positive qNaN instead of negative. For floats, qNaN is 0x7fff_ffff. For
doubles, qNaN is 0x7fff_ffff_ffff_ffff.

Return correctly signed zero on float and double divide underflow. This means
that Ld$underflow now expects d7 to contain the sign bit, just like the other
return paths.

libgcc/
* config/m68k/fpgnulib.c (extenddfxf2): Simplify code by removing code
that should never execute.  Fix denorm shift test and insert hidden bit
as needed.
(__truncxfdf2): Properly compue and shift the significant right.
* config/m68k/lb1sf68.S (__fixxfsi): Correct shift counts and simplify.
(QUIET_NAN): Make it a positive quiet NaN and fix return values to inject
sign properly.

6 months agoPrefer scalar_int_mode if the size - 1 is equal to UNITS_PER_WORD.
Tsung Chun Lin [Tue, 7 Jan 2025 21:48:31 +0000 (14:48 -0700)] 
Prefer scalar_int_mode if the size - 1 is equal to UNITS_PER_WORD.

Don't use the QI vector if its size is equal to UNITS_PER_WORD for
better code generation.

Before patch:

vsetivli        zero,4,e8,mf4,ta,ma
vmv.v.i v1,0
addi    a4,sp,12
vse8.v  v1,0(a4)

After patch:

sw      zero,12(sp)

gcc/
* expr.cc (widest_fixed_size_mode_for_size): Prefer scalar modes
over vector modes in more cases.

gcc/testsuite/

* gcc.target/riscv/rvv/autovec/pr113469.c: Update expected output.
* gcc.target/riscv/rvv/base/movqi-1.c: New test.

6 months agoFix testsuite expectations for RVV after recent change
Jeff Law [Tue, 7 Jan 2025 21:27:28 +0000 (14:27 -0700)] 
Fix testsuite expectations for RVV after recent change

Tamar's recent improvement to improve affine unsigned folding for exchange2
twiddle code generation for a couple tests in the RVV testsuite just enough to
cause testsuite failures.

I've looked at both tests before/after Tamar's change and the code is clearly
better -- essentially tighter vector loops due to improvements in address
arithmetic.  Additionally we have fewer vsetvls after Tamar's patch.

Given that I'm just making the obvious adjustments to the expected assembly and
pushing to the trunk.

gcc/testsuite
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-3.c: Update expected
output.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-12.c: Likewise.

6 months ago[PATCH] testsuite: enable effective-target sync_char_short on RISC-V
Andreas Schwab [Tue, 7 Jan 2025 19:31:39 +0000 (12:31 -0700)] 
[PATCH] testsuite: enable effective-target sync_char_short on RISC-V

gcc/testuite/
* lib/target-supports.exp
(check_effective_target_sync_char_short): Enable for riscv*-*-*.

6 months ago[PATCH] riscv: add mising masking in lrsc expander (PR118137)
Andreas Schwab [Tue, 7 Jan 2025 19:23:37 +0000 (12:23 -0700)] 
[PATCH] riscv: add mising masking in lrsc expander (PR118137)

gcc:
PR target/118137
* config/riscv/sync.md ("lrsc_atomic_exchange<mode>"): Apply mask
to shifted value.

gcc/testsuite:
PR target/118137
* gcc.dg/atomic/pr118137.c: New.

6 months agoFix regression in ft32 port after recent switch table adjustments
Jeff Law [Tue, 7 Jan 2025 19:20:15 +0000 (12:20 -0700)] 
Fix regression in ft32 port after recent switch table adjustments

This is a trivial bug that showed up after Mark W's recent patch to not apply
the size limit on jump tables.

The ft32 port has limited immediate ranges on comparisons and the casesi
expander didn't honor those.  It'd blindly pass along an out of range constant.

This patch adds the trivial adjustment to force an out of range constant into a
register.  It fixes these regressions:

> Tests that now fail, but worked before (3 tests):
>
> ft32-sim: gcc: gcc.c-torture/compile/pr34093.c   -O1  (test for excess errors)
> ft32-sim: gcc: gcc.dg/torture/pr106809.c   -O1  (test for excess errors)
> ft32-sim: gcc: gcc.dg/torture/pr106809.c   -O1  (test for excess errors)
Tested in my tester.    No other tests were fixed.

gcc/
* config/ft32/ft32.md (casesi expander): Force operands[2] into
a register if it's not a suitable rimm operand.

6 months agotestsuite: RISC-V: Skip tests providing -march for ILP32E/ILP64E ABIs
Dimitar Dimitrov [Sun, 24 Nov 2024 10:22:13 +0000 (12:22 +0200)] 
testsuite: RISC-V: Skip tests providing -march for ILP32E/ILP64E ABIs

Many test cases explicitly set -march with extensions which are not
compatible with the E ABI variants.  This leads to spurious errors
when toolchain has been configured for RV32E base ISA and ILP32E ABI:

  spawn ... -march=rv32gc_zbb ...
  cc1: error: ILP32E ABI does not support the 'D' extension

Fix by skipping those tests if toolchain's default ABI is E.

gcc/testsuite/ChangeLog:

* gcc.dg/pr90838-2.c: Skip if default ABI is E.
* gcc.dg/pr90838.c: Ditto.
* gcc.target/riscv/adddibeq.c: Ditto.
* gcc.target/riscv/adddibfeq.c: Ditto.
* gcc.target/riscv/adddibfge.c: Ditto.
* gcc.target/riscv/adddibfgt.c: Ditto.
* gcc.target/riscv/adddibfle.c: Ditto.
* gcc.target/riscv/adddibflt.c: Ditto.
* gcc.target/riscv/adddibfne.c: Ditto.
* gcc.target/riscv/adddibge.c: Ditto.
* gcc.target/riscv/adddibgeu.c: Ditto.
* gcc.target/riscv/adddibgt.c: Ditto.
* gcc.target/riscv/adddibgtu.c: Ditto.
* gcc.target/riscv/adddible.c: Ditto.
* gcc.target/riscv/adddibleu.c: Ditto.
* gcc.target/riscv/adddiblt.c: Ditto.
* gcc.target/riscv/adddibltu.c: Ditto.
* gcc.target/riscv/adddibne.c: Ditto.
* gcc.target/riscv/adddieq.c: Ditto.
* gcc.target/riscv/adddifeq.c: Ditto.
* gcc.target/riscv/adddifge.c: Ditto.
* gcc.target/riscv/adddifgt.c: Ditto.
* gcc.target/riscv/adddifle.c: Ditto.
* gcc.target/riscv/adddiflt.c: Ditto.
* gcc.target/riscv/adddifne.c: Ditto.
* gcc.target/riscv/adddige.c: Ditto.
* gcc.target/riscv/adddigeu.c: Ditto.
* gcc.target/riscv/adddigt.c: Ditto.
* gcc.target/riscv/adddigtu.c: Ditto.
* gcc.target/riscv/adddile.c: Ditto.
* gcc.target/riscv/adddileu.c: Ditto.
* gcc.target/riscv/adddilt.c: Ditto.
* gcc.target/riscv/adddiltu.c: Ditto.
* gcc.target/riscv/adddine.c: Ditto.
* gcc.target/riscv/addsibeq.c: Ditto.
* gcc.target/riscv/addsibfeq.c: Ditto.
* gcc.target/riscv/addsibfge.c: Ditto.
* gcc.target/riscv/addsibfgt.c: Ditto.
* gcc.target/riscv/addsibfle.c: Ditto.
* gcc.target/riscv/addsibflt.c: Ditto.
* gcc.target/riscv/addsibfne.c: Ditto.
* gcc.target/riscv/addsibge.c: Ditto.
* gcc.target/riscv/addsibgeu.c: Ditto.
* gcc.target/riscv/addsibgt.c: Ditto.
* gcc.target/riscv/addsibgtu.c: Ditto.
* gcc.target/riscv/addsible.c: Ditto.
* gcc.target/riscv/addsibleu.c: Ditto.
* gcc.target/riscv/addsiblt.c: Ditto.
* gcc.target/riscv/addsibltu.c: Ditto.
* gcc.target/riscv/addsibne.c: Ditto.
* gcc.target/riscv/addsieq.c: Ditto.
* gcc.target/riscv/addsifeq.c: Ditto.
* gcc.target/riscv/addsifge.c: Ditto.
* gcc.target/riscv/addsifgt.c: Ditto.
* gcc.target/riscv/addsifle.c: Ditto.
* gcc.target/riscv/addsiflt.c: Ditto.
* gcc.target/riscv/addsifne.c: Ditto.
* gcc.target/riscv/addsige.c: Ditto.
* gcc.target/riscv/addsigeu.c: Ditto.
* gcc.target/riscv/addsigt.c: Ditto.
* gcc.target/riscv/addsigtu.c: Ditto.
* gcc.target/riscv/addsile.c: Ditto.
* gcc.target/riscv/addsileu.c: Ditto.
* gcc.target/riscv/addsilt.c: Ditto.
* gcc.target/riscv/addsiltu.c: Ditto.
* gcc.target/riscv/addsine.c: Ditto.
* gcc.target/riscv/cmo-zicboz-zic64-1.c: Ditto.
* gcc.target/riscv/cmpmemsi-2.c: Ditto.
* gcc.target/riscv/cmpmemsi-3.c: Ditto.
* gcc.target/riscv/cmpmemsi.c: Ditto.
* gcc.target/riscv/cpymemsi-2.c: Ditto.
* gcc.target/riscv/cpymemsi-3.c: Ditto.
* gcc.target/riscv/cpymemsi.c: Ditto.
* gcc.target/riscv/crc-builtin-zbc32.c: Ditto.
* gcc.target/riscv/crc-builtin-zbc64.c: Ditto.
* gcc.target/riscv/cset-sext-rtl.c: Ditto.
* gcc.target/riscv/cset-sext-rtl32.c: Ditto.
* gcc.target/riscv/cset-sext-sfb-rtl.c: Ditto.
* gcc.target/riscv/cset-sext-sfb-rtl32.c: Ditto.
* gcc.target/riscv/cset-sext-sfb.c: Ditto.
* gcc.target/riscv/cset-sext-thead-rtl.c: Ditto.
* gcc.target/riscv/cset-sext-thead.c: Ditto.
* gcc.target/riscv/cset-sext-ventana-rtl.c: Ditto.
* gcc.target/riscv/cset-sext-ventana.c: Ditto.
* gcc.target/riscv/cset-sext-zicond-rtl.c: Ditto.
* gcc.target/riscv/cset-sext-zicond-rtl32.c: Ditto.
* gcc.target/riscv/cset-sext-zicond.c: Ditto.
* gcc.target/riscv/cset-sext.c: Ditto.
* gcc.target/riscv/matrix_add_const.c: Ditto.
* gcc.target/riscv/movdibeq-thead.c: Ditto.
* gcc.target/riscv/movdibeq-ventana.c: Ditto.
* gcc.target/riscv/movdibeq-zicond.c: Ditto.
* gcc.target/riscv/movdibeq.c: Ditto.
* gcc.target/riscv/movdibfeq-ventana.c: Ditto.
* gcc.target/riscv/movdibfeq-zicond.c: Ditto.
* gcc.target/riscv/movdibfeq.c: Ditto.
* gcc.target/riscv/movdibfge-ventana.c: Ditto.
* gcc.target/riscv/movdibfge-zicond.c: Ditto.
* gcc.target/riscv/movdibfge.c: Ditto.
* gcc.target/riscv/movdibfgt-ventana.c: Ditto.
* gcc.target/riscv/movdibfgt-zicond.c: Ditto.
* gcc.target/riscv/movdibfgt.c: Ditto.
* gcc.target/riscv/movdibfle-ventana.c: Ditto.
* gcc.target/riscv/movdibfle-zicond.c: Ditto.
* gcc.target/riscv/movdibfle.c: Ditto.
* gcc.target/riscv/movdibflt-ventana.c: Ditto.
* gcc.target/riscv/movdibflt-zicond.c: Ditto.
* gcc.target/riscv/movdibflt.c: Ditto.
* gcc.target/riscv/movdibfne-ventana.c: Ditto.
* gcc.target/riscv/movdibfne-zicond.c: Ditto.
* gcc.target/riscv/movdibfne.c: Ditto.
* gcc.target/riscv/movdibge-thead.c: Ditto.
* gcc.target/riscv/movdibge-ventana.c: Ditto.
* gcc.target/riscv/movdibge-zicond.c: Ditto.
* gcc.target/riscv/movdibge.c: Ditto.
* gcc.target/riscv/movdibgeu-thead.c: Ditto.
* gcc.target/riscv/movdibgeu-ventana.c: Ditto.
* gcc.target/riscv/movdibgeu-zicond.c: Ditto.
* gcc.target/riscv/movdibgeu.c: Ditto.
* gcc.target/riscv/movdibgt-thead.c: Ditto.
* gcc.target/riscv/movdibgt-ventana.c: Ditto.
* gcc.target/riscv/movdibgt-zicond.c: Ditto.
* gcc.target/riscv/movdibgt.c: Ditto.
* gcc.target/riscv/movdibgtu-thead.c: Ditto.
* gcc.target/riscv/movdibgtu-ventana.c: Ditto.
* gcc.target/riscv/movdibgtu-zicond.c: Ditto.
* gcc.target/riscv/movdibgtu.c: Ditto.
* gcc.target/riscv/movdible-thead.c: Ditto.
* gcc.target/riscv/movdible-ventana.c: Ditto.
* gcc.target/riscv/movdible-zicond.c: Ditto.
* gcc.target/riscv/movdible.c: Ditto.
* gcc.target/riscv/movdibleu-thead.c: Ditto.
* gcc.target/riscv/movdibleu-ventana.c: Ditto.
* gcc.target/riscv/movdibleu-zicond.c: Ditto.
* gcc.target/riscv/movdibleu.c: Ditto.
* gcc.target/riscv/movdiblt-thead.c: Ditto.
* gcc.target/riscv/movdiblt-ventana.c: Ditto.
* gcc.target/riscv/movdiblt-zicond.c: Ditto.
* gcc.target/riscv/movdiblt.c: Ditto.
* gcc.target/riscv/movdibltu-thead.c: Ditto.
* gcc.target/riscv/movdibltu-ventana.c: Ditto.
* gcc.target/riscv/movdibltu-zicond.c: Ditto.
* gcc.target/riscv/movdibltu.c: Ditto.
* gcc.target/riscv/movdibne-thead.c: Ditto.
* gcc.target/riscv/movdibne-ventana.c: Ditto.
* gcc.target/riscv/movdibne-zicond.c: Ditto.
* gcc.target/riscv/movdibne.c: Ditto.
* gcc.target/riscv/movdieq-sfb.c: Ditto.
* gcc.target/riscv/movdieq-thead.c: Ditto.
* gcc.target/riscv/movdieq-ventana.c: Ditto.
* gcc.target/riscv/movdieq-zicond.c: Ditto.
* gcc.target/riscv/movdieq.c: Ditto.
* gcc.target/riscv/movdifeq-sfb.c: Ditto.
* gcc.target/riscv/movdifeq-thead.c: Ditto.
* gcc.target/riscv/movdifeq-ventana.c: Ditto.
* gcc.target/riscv/movdifeq-zicond.c: Ditto.
* gcc.target/riscv/movdifeq.c: Ditto.
* gcc.target/riscv/movdifge-sfb.c: Ditto.
* gcc.target/riscv/movdifge-thead.c: Ditto.
* gcc.target/riscv/movdifge-ventana.c: Ditto.
* gcc.target/riscv/movdifge-zicond.c: Ditto.
* gcc.target/riscv/movdifge.c: Ditto.
* gcc.target/riscv/movdifgt-sfb.c: Ditto.
* gcc.target/riscv/movdifgt-thead.c: Ditto.
* gcc.target/riscv/movdifgt-ventana.c: Ditto.
* gcc.target/riscv/movdifgt-zicond.c: Ditto.
* gcc.target/riscv/movdifgt.c: Ditto.
* gcc.target/riscv/movdifle-sfb.c: Ditto.
* gcc.target/riscv/movdifle-thead.c: Ditto.
* gcc.target/riscv/movdifle-ventana.c: Ditto.
* gcc.target/riscv/movdifle-zicond.c: Ditto.
* gcc.target/riscv/movdifle.c: Ditto.
* gcc.target/riscv/movdiflt-sfb.c: Ditto.
* gcc.target/riscv/movdiflt-thead.c: Ditto.
* gcc.target/riscv/movdiflt-ventana.c: Ditto.
* gcc.target/riscv/movdiflt-zicond.c: Ditto.
* gcc.target/riscv/movdiflt.c: Ditto.
* gcc.target/riscv/movdifne-sfb.c: Ditto.
* gcc.target/riscv/movdifne-thead.c: Ditto.
* gcc.target/riscv/movdifne-ventana.c: Ditto.
* gcc.target/riscv/movdifne-zicond.c: Ditto.
* gcc.target/riscv/movdifne.c: Ditto.
* gcc.target/riscv/movdige-sfb.c: Ditto.
* gcc.target/riscv/movdige-thead.c: Ditto.
* gcc.target/riscv/movdige-ventana.c: Ditto.
* gcc.target/riscv/movdige-zicond.c: Ditto.
* gcc.target/riscv/movdige.c: Ditto.
* gcc.target/riscv/movdigeu-sfb.c: Ditto.
* gcc.target/riscv/movdigeu-thead.c: Ditto.
* gcc.target/riscv/movdigeu-ventana.c: Ditto.
* gcc.target/riscv/movdigeu-zicond.c: Ditto.
* gcc.target/riscv/movdigeu.c: Ditto.
* gcc.target/riscv/movdigt-sfb.c: Ditto.
* gcc.target/riscv/movdigt-thead.c: Ditto.
* gcc.target/riscv/movdigt-ventana.c: Ditto.
* gcc.target/riscv/movdigt-zicond.c: Ditto.
* gcc.target/riscv/movdigt.c: Ditto.
* gcc.target/riscv/movdigtu-sfb.c: Ditto.
* gcc.target/riscv/movdigtu-thead.c: Ditto.
* gcc.target/riscv/movdigtu-ventana.c: Ditto.
* gcc.target/riscv/movdigtu-zicond.c: Ditto.
* gcc.target/riscv/movdigtu.c: Ditto.
* gcc.target/riscv/movdile-sfb.c: Ditto.
* gcc.target/riscv/movdile-thead.c: Ditto.
* gcc.target/riscv/movdile-ventana.c: Ditto.
* gcc.target/riscv/movdile-zicond.c: Ditto.
* gcc.target/riscv/movdile.c: Ditto.
* gcc.target/riscv/movdileu-sfb.c: Ditto.
* gcc.target/riscv/movdileu-thead.c: Ditto.
* gcc.target/riscv/movdileu-ventana.c: Ditto.
* gcc.target/riscv/movdileu-zicond.c: Ditto.
* gcc.target/riscv/movdileu.c: Ditto.
* gcc.target/riscv/movdilt-sfb.c: Ditto.
* gcc.target/riscv/movdilt-thead.c: Ditto.
* gcc.target/riscv/movdilt-ventana.c: Ditto.
* gcc.target/riscv/movdilt-zicond.c: Ditto.
* gcc.target/riscv/movdilt.c: Ditto.
* gcc.target/riscv/movdiltu-sfb.c: Ditto.
* gcc.target/riscv/movdiltu-thead.c: Ditto.
* gcc.target/riscv/movdiltu-ventana.c: Ditto.
* gcc.target/riscv/movdiltu-zicond.c: Ditto.
* gcc.target/riscv/movdiltu.c: Ditto.
* gcc.target/riscv/movdine-sfb.c: Ditto.
* gcc.target/riscv/movdine-thead.c: Ditto.
* gcc.target/riscv/movdine-ventana.c: Ditto.
* gcc.target/riscv/movdine-zicond.c: Ditto.
* gcc.target/riscv/movdine.c: Ditto.
* gcc.target/riscv/movsibeq-thead.c: Ditto.
* gcc.target/riscv/movsibeq-ventana.c: Ditto.
* gcc.target/riscv/movsibeq-zicond.c: Ditto.
* gcc.target/riscv/movsibeq.c: Ditto.
* gcc.target/riscv/movsibfeq-ventana.c: Ditto.
* gcc.target/riscv/movsibfeq-zicond.c: Ditto.
* gcc.target/riscv/movsibfeq.c: Ditto.
* gcc.target/riscv/movsibfge-ventana.c: Ditto.
* gcc.target/riscv/movsibfge-zicond.c: Ditto.
* gcc.target/riscv/movsibfge.c: Ditto.
* gcc.target/riscv/movsibfgt-ventana.c: Ditto.
* gcc.target/riscv/movsibfgt-zicond.c: Ditto.
* gcc.target/riscv/movsibfgt.c: Ditto.
* gcc.target/riscv/movsibfle-ventana.c: Ditto.
* gcc.target/riscv/movsibfle-zicond.c: Ditto.
* gcc.target/riscv/movsibfle.c: Ditto.
* gcc.target/riscv/movsibflt-ventana.c: Ditto.
* gcc.target/riscv/movsibflt-zicond.c: Ditto.
* gcc.target/riscv/movsibflt.c: Ditto.
* gcc.target/riscv/movsibfne-ventana.c: Ditto.
* gcc.target/riscv/movsibfne-zicond.c: Ditto.
* gcc.target/riscv/movsibfne.c: Ditto.
* gcc.target/riscv/movsibge-thead.c: Ditto.
* gcc.target/riscv/movsibge-ventana.c: Ditto.
* gcc.target/riscv/movsibge-zicond.c: Ditto.
* gcc.target/riscv/movsibge.c: Ditto.
* gcc.target/riscv/movsibgeu-thead.c: Ditto.
* gcc.target/riscv/movsibgeu-ventana.c: Ditto.
* gcc.target/riscv/movsibgeu-zicond.c: Ditto.
* gcc.target/riscv/movsibgeu.c: Ditto.
* gcc.target/riscv/movsibgt-thead.c: Ditto.
* gcc.target/riscv/movsibgt-ventana.c: Ditto.
* gcc.target/riscv/movsibgt-zicond.c: Ditto.
* gcc.target/riscv/movsibgt.c: Ditto.
* gcc.target/riscv/movsibgtu-thead.c: Ditto.
* gcc.target/riscv/movsibgtu-ventana.c: Ditto.
* gcc.target/riscv/movsibgtu-zicond.c: Ditto.
* gcc.target/riscv/movsibgtu.c: Ditto.
* gcc.target/riscv/movsible-thead.c: Ditto.
* gcc.target/riscv/movsible-ventana.c: Ditto.
* gcc.target/riscv/movsible-zicond.c: Ditto.
* gcc.target/riscv/movsible.c: Ditto.
* gcc.target/riscv/movsibleu-thead.c: Ditto.
* gcc.target/riscv/movsibleu-ventana.c: Ditto.
* gcc.target/riscv/movsibleu-zicond.c: Ditto.
* gcc.target/riscv/movsibleu.c: Ditto.
* gcc.target/riscv/movsiblt-thead.c: Ditto.
* gcc.target/riscv/movsiblt-ventana.c: Ditto.
* gcc.target/riscv/movsiblt-zicond.c: Ditto.
* gcc.target/riscv/movsiblt.c: Ditto.
* gcc.target/riscv/movsibltu-thead.c: Ditto.
* gcc.target/riscv/movsibltu-ventana.c: Ditto.
* gcc.target/riscv/movsibltu-zicond.c: Ditto.
* gcc.target/riscv/movsibltu.c: Ditto.
* gcc.target/riscv/movsibne-thead.c: Ditto.
* gcc.target/riscv/movsibne-ventana.c: Ditto.
* gcc.target/riscv/movsibne-zicond.c: Ditto.
* gcc.target/riscv/movsibne.c: Ditto.
* gcc.target/riscv/movsieq-sfb.c: Ditto.
* gcc.target/riscv/movsieq-thead.c: Ditto.
* gcc.target/riscv/movsieq-ventana.c: Ditto.
* gcc.target/riscv/movsieq-zicond.c: Ditto.
* gcc.target/riscv/movsieq.c: Ditto.
* gcc.target/riscv/movsifeq-sfb.c: Ditto.
* gcc.target/riscv/movsifeq-thead.c: Ditto.
* gcc.target/riscv/movsifeq-ventana.c: Ditto.
* gcc.target/riscv/movsifeq-zicond.c: Ditto.
* gcc.target/riscv/movsifeq.c: Ditto.
* gcc.target/riscv/movsifge-sfb.c: Ditto.
* gcc.target/riscv/movsifge-thead.c: Ditto.
* gcc.target/riscv/movsifge-ventana.c: Ditto.
* gcc.target/riscv/movsifge-zicond.c: Ditto.
* gcc.target/riscv/movsifge.c: Ditto.
* gcc.target/riscv/movsifgt-sfb.c: Ditto.
* gcc.target/riscv/movsifgt-thead.c: Ditto.
* gcc.target/riscv/movsifgt-ventana.c: Ditto.
* gcc.target/riscv/movsifgt-zicond.c: Ditto.
* gcc.target/riscv/movsifgt.c: Ditto.
* gcc.target/riscv/movsifle-sfb.c: Ditto.
* gcc.target/riscv/movsifle-thead.c: Ditto.
* gcc.target/riscv/movsifle-ventana.c: Ditto.
* gcc.target/riscv/movsifle-zicond.c: Ditto.
* gcc.target/riscv/movsifle.c: Ditto.
* gcc.target/riscv/movsiflt-sfb.c: Ditto.
* gcc.target/riscv/movsiflt-thead.c: Ditto.
* gcc.target/riscv/movsiflt-ventana.c: Ditto.
* gcc.target/riscv/movsiflt-zicond.c: Ditto.
* gcc.target/riscv/movsiflt.c: Ditto.
* gcc.target/riscv/movsifne-sfb.c: Ditto.
* gcc.target/riscv/movsifne-thead.c: Ditto.
* gcc.target/riscv/movsifne-ventana.c: Ditto.
* gcc.target/riscv/movsifne-zicond.c: Ditto.
* gcc.target/riscv/movsifne.c: Ditto.
* gcc.target/riscv/movsige-sfb.c: Ditto.
* gcc.target/riscv/movsige-thead.c: Ditto.
* gcc.target/riscv/movsige-ventana.c: Ditto.
* gcc.target/riscv/movsige-zicond.c: Ditto.
* gcc.target/riscv/movsige.c: Ditto.
* gcc.target/riscv/movsigeu-sfb.c: Ditto.
* gcc.target/riscv/movsigeu-thead.c: Ditto.
* gcc.target/riscv/movsigeu-ventana.c: Ditto.
* gcc.target/riscv/movsigeu-zicond.c: Ditto.
* gcc.target/riscv/movsigeu.c: Ditto.
* gcc.target/riscv/movsigt-sfb.c: Ditto.
* gcc.target/riscv/movsigt-thead.c: Ditto.
* gcc.target/riscv/movsigt-ventana.c: Ditto.
* gcc.target/riscv/movsigt-zicond.c: Ditto.
* gcc.target/riscv/movsigt.c: Ditto.
* gcc.target/riscv/movsigtu-sfb.c: Ditto.
* gcc.target/riscv/movsigtu-thead.c: Ditto.
* gcc.target/riscv/movsigtu-ventana.c: Ditto.
* gcc.target/riscv/movsigtu-zicond.c: Ditto.
* gcc.target/riscv/movsigtu.c: Ditto.
* gcc.target/riscv/movsile-sfb.c: Ditto.
* gcc.target/riscv/movsile-thead.c: Ditto.
* gcc.target/riscv/movsile-ventana.c: Ditto.
* gcc.target/riscv/movsile-zicond.c: Ditto.
* gcc.target/riscv/movsile.c: Ditto.
* gcc.target/riscv/movsileu-sfb.c: Ditto.
* gcc.target/riscv/movsileu-thead.c: Ditto.
* gcc.target/riscv/movsileu-ventana.c: Ditto.
* gcc.target/riscv/movsileu-zicond.c: Ditto.
* gcc.target/riscv/movsileu.c: Ditto.
* gcc.target/riscv/movsilt-sfb.c: Ditto.
* gcc.target/riscv/movsilt-thead.c: Ditto.
* gcc.target/riscv/movsilt-ventana.c: Ditto.
* gcc.target/riscv/movsilt-zicond.c: Ditto.
* gcc.target/riscv/movsilt.c: Ditto.
* gcc.target/riscv/movsiltu-sfb.c: Ditto.
* gcc.target/riscv/movsiltu-thead.c: Ditto.
* gcc.target/riscv/movsiltu-ventana.c: Ditto.
* gcc.target/riscv/movsiltu-zicond.c: Ditto.
* gcc.target/riscv/movsiltu.c: Ditto.
* gcc.target/riscv/movsine-sfb.c: Ditto.
* gcc.target/riscv/movsine-thead.c: Ditto.
* gcc.target/riscv/movsine-ventana.c: Ditto.
* gcc.target/riscv/movsine-zicond.c: Ditto.
* gcc.target/riscv/movsine.c: Ditto.
* gcc.target/riscv/pr111501.c: Ditto.
* gcc.target/riscv/pr115921.c: Ditto.
* gcc.target/riscv/pr116033.c: Ditto.
* gcc.target/riscv/pr116035-1.c: Ditto.
* gcc.target/riscv/pr116035-2.c: Ditto.
* gcc.target/riscv/pr116131.c: Ditto.
* gcc.target/riscv/reg_subreg_costs.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slide.c: Ditto.
* gcc.target/riscv/rvv/xtheadvector.c: Ditto.
* gcc.target/riscv/rvv/xtheadvector/pr114194.c: Ditto.
* gcc.target/riscv/sign-extend-rshift-32.c: Ditto.
* gcc.target/riscv/sign-extend-rshift-64.c: Ditto.
* gcc.target/riscv/sign-extend-rshift.c: Ditto.
* gcc.target/riscv/synthesis-1.c: Ditto.
* gcc.target/riscv/synthesis-10.c: Ditto.
* gcc.target/riscv/synthesis-11.c: Ditto.
* gcc.target/riscv/synthesis-12.c: Ditto.
* gcc.target/riscv/synthesis-13.c: Ditto.
* gcc.target/riscv/synthesis-14.c: Ditto.
* gcc.target/riscv/synthesis-15.c: Ditto.
* gcc.target/riscv/synthesis-16.c: Ditto.
* gcc.target/riscv/synthesis-2.c: Ditto.
* gcc.target/riscv/synthesis-3.c: Ditto.
* gcc.target/riscv/synthesis-4.c: Ditto.
* gcc.target/riscv/synthesis-5.c: Ditto.
* gcc.target/riscv/synthesis-6.c: Ditto.
* gcc.target/riscv/synthesis-7.c: Ditto.
* gcc.target/riscv/synthesis-8.c: Ditto.
* gcc.target/riscv/synthesis-9.c: Ditto.
* gcc.target/riscv/target-attr-16.c: Ditto.
* gcc.target/riscv/target-attr-norelax.c: Ditto.
* gcc.target/riscv/xtheadba-addsl.c: Ditto.
* gcc.target/riscv/xtheadba.c: Ditto.
* gcc.target/riscv/xtheadbb-ext-1.c: Ditto.
* gcc.target/riscv/xtheadbb-ext-2.c: Ditto.
* gcc.target/riscv/xtheadbb-ext-3.c: Ditto.
* gcc.target/riscv/xtheadbb-ext.c: Ditto.
* gcc.target/riscv/xtheadbb-extu-1.c: Ditto.
* gcc.target/riscv/xtheadbb-extu-2.c: Ditto.
* gcc.target/riscv/xtheadbb-extu-4.c: Ditto.
* gcc.target/riscv/xtheadbb-extu.c: Ditto.
* gcc.target/riscv/xtheadbb-ff1.c: Ditto.
* gcc.target/riscv/xtheadbb-rev.c: Ditto.
* gcc.target/riscv/xtheadbb-srri.c: Ditto.
* gcc.target/riscv/xtheadbb-strcmp.c: Ditto.
* gcc.target/riscv/xtheadbb-strlen-unaligned.c: Ditto.
* gcc.target/riscv/xtheadbb-strlen.c: Ditto.
* gcc.target/riscv/xtheadbb.c: Ditto.
* gcc.target/riscv/xtheadbs-tst.c: Ditto.
* gcc.target/riscv/xtheadbs.c: Ditto.
* gcc.target/riscv/xtheadcmo.c: Ditto.
* gcc.target/riscv/xtheadcondmov-indirect.c: Ditto.
* gcc.target/riscv/xtheadcondmov-mveqz-imm-eqz.c: Ditto.
* gcc.target/riscv/xtheadcondmov-mveqz-imm-not.c: Ditto.
* gcc.target/riscv/xtheadcondmov-mveqz-reg-eqz.c: Ditto.
* gcc.target/riscv/xtheadcondmov-mveqz-reg-not.c: Ditto.
* gcc.target/riscv/xtheadcondmov-mvnez-imm-cond.c: Ditto.
* gcc.target/riscv/xtheadcondmov-mvnez-imm-nez.c: Ditto.
* gcc.target/riscv/xtheadcondmov-mvnez-reg-cond.c: Ditto.
* gcc.target/riscv/xtheadcondmov-mvnez-reg-nez.c: Ditto.
* gcc.target/riscv/xtheadcondmov.c: Ditto.
* gcc.target/riscv/xtheadfmemidx-without-xtheadmemidx.c: Ditto.
* gcc.target/riscv/xtheadfmemidx.c: Ditto.
* gcc.target/riscv/xtheadfmv.c: Ditto.
* gcc.target/riscv/xtheadint.c: Ditto.
* gcc.target/riscv/xtheadmac-mula-muls.c: Ditto.
* gcc.target/riscv/xtheadmac.c: Ditto.
* gcc.target/riscv/xtheadmemidx-index-update.c: Ditto.
* gcc.target/riscv/xtheadmemidx-index-xtheadbb-update.c: Ditto.
* gcc.target/riscv/xtheadmemidx-index-xtheadbb.c: Ditto.
* gcc.target/riscv/xtheadmemidx-index.c: Ditto.
* gcc.target/riscv/xtheadmemidx-modify-xtheadbb.c: Ditto.
* gcc.target/riscv/xtheadmemidx-modify.c: Ditto.
* gcc.target/riscv/xtheadmemidx-uindex-update.c: Ditto.
* gcc.target/riscv/xtheadmemidx-uindex-xtheadbb-update.c: Ditto.
* gcc.target/riscv/xtheadmemidx-uindex-xtheadbb.c: Ditto.
* gcc.target/riscv/xtheadmemidx-uindex.c: Ditto.
* gcc.target/riscv/xtheadmemidx.c: Ditto.
* gcc.target/riscv/xtheadmempair-1.c: Ditto.
* gcc.target/riscv/xtheadmempair-2.c: Ditto.
* gcc.target/riscv/xtheadmempair-3.c: Ditto.
* gcc.target/riscv/xtheadmempair-4.c: Ditto.
* gcc.target/riscv/xtheadmempair-interrupt-fcsr.c: Ditto.
* gcc.target/riscv/xtheadmempair.c: Ditto.
* gcc.target/riscv/xtheadsync.c: Ditto.
* gcc.target/riscv/za-ext.c: Ditto.
* gcc.target/riscv/zawrs.c: Ditto.
* gcc.target/riscv/zbb-strcmp-disabled-2.c: Ditto.
* gcc.target/riscv/zbb-strcmp-disabled.c: Ditto.
* gcc.target/riscv/zbb-strcmp-limit.c: Ditto.
* gcc.target/riscv/zbb-strcmp-unaligned.c: Ditto.
* gcc.target/riscv/zbb-strcmp.c: Ditto.
* gcc.target/riscv/zbb-strlen-disabled-2.c: Ditto.
* gcc.target/riscv/zbb-strlen-disabled.c: Ditto.
* gcc.target/riscv/zbb-strlen-unaligned.c: Ditto.
* gcc.target/riscv/zbb-strlen.c: Ditto.
* gcc.target/riscv/zero-extend-rshift-32.c: Ditto.
* gcc.target/riscv/zero-extend-rshift-64.c: Ditto.
* gcc.target/riscv/zero-extend-rshift.c: Ditto.
* gcc.target/riscv/zi-ext.c: Ditto.
* gcc.target/riscv/zvbb.c: Ditto.
* gcc.target/riscv/zvbc.c: Ditto.
* gcc.target/riscv/zvkb.c: Ditto.
* gcc.target/riscv/zvkg.c: Ditto.
* gcc.target/riscv/zvkn-1.c: Ditto.
* gcc.target/riscv/zvkn.c: Ditto.
* gcc.target/riscv/zvknc-1.c: Ditto.
* gcc.target/riscv/zvknc-2.c: Ditto.
* gcc.target/riscv/zvknc.c: Ditto.
* gcc.target/riscv/zvkned.c: Ditto.
* gcc.target/riscv/zvkng-1.c: Ditto.
* gcc.target/riscv/zvkng-2.c: Ditto.
* gcc.target/riscv/zvkng.c: Ditto.
* gcc.target/riscv/zvknha.c: Ditto.
* gcc.target/riscv/zvknhb.c: Ditto.
* gcc.target/riscv/zvks-1.c: Ditto.
* gcc.target/riscv/zvks.c: Ditto.
* gcc.target/riscv/zvksc-1.c: Ditto.
* gcc.target/riscv/zvksc-2.c: Ditto.
* gcc.target/riscv/zvksc.c: Ditto.
* gcc.target/riscv/zvksed.c: Ditto.
* gcc.target/riscv/zvksg-1.c: Ditto.
* gcc.target/riscv/zvksg-2.c: Ditto.
* gcc.target/riscv/zvksg.c: Ditto.
* gcc.target/riscv/zvksh.c: Ditto.
* gcc.target/riscv/zvkt.c: Ditto.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
6 months agotestsuite: RISC-V: Skip tests using -mcpu= for ILP32E/ILP64E ABIs
Dimitar Dimitrov [Wed, 4 Dec 2024 15:51:11 +0000 (17:51 +0200)] 
testsuite: RISC-V: Skip tests using -mcpu= for ILP32E/ILP64E ABIs

The tests are specifying -mcpu with D extension, which is not compatible
with the ILP32E and ILP64E ABIs.  Fix by skipping the tests if toolchain's
default ABI is an E variant.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr109508.c: Skip for E ABI.
* gcc.target/riscv/pr114139.c: Ditto.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
6 months agotestsuite: RISC-V: Skip V and Zvbb tests for ILP32E/ILP64E ABIs
Dimitar Dimitrov [Mon, 25 Nov 2024 18:48:00 +0000 (20:48 +0200)] 
testsuite: RISC-V: Skip V and Zvbb tests for ILP32E/ILP64E ABIs

Some tests add options for V and Zvbb extensions, but those extensions
are not compatible with the E ABI variants.  This leads to spurious test
failures when toolchain's default ABI is ILP32E or ILP64E:

  spawn ... -march=rv32ecv_zvbb ...
  cc1: error: ILP32E ABI does not support the 'D' extension
  cc1: sorry, unimplemented: Currently the 'V' implementation requires the 'M' extension

Fix by skipping the tests when toolchain's default ABI is E variant.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vandn-1.c: Skip if default
is E ABI.
* gcc.target/riscv/rvv/autovec/binop/vrolr-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vwsll-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vwsll-template.h: Ditto.
* gcc.target/riscv/rvv/autovec/gather-scatter/gather_load_64-12-zvbb.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/clz-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/ctz-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/popcount-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/popcount-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/unop/popcount-3.c: Ditto.
* gcc.target/riscv/rvv/base/cmpmem-1.c: Ditto.
* gcc.target/riscv/rvv/base/cmpmem-3.c: Ditto.
* gcc.target/riscv/rvv/base/cmpmem-4.c: Ditto.
* gcc.target/riscv/rvv/base/cpymem-1.c: Ditto.
* gcc.target/riscv/rvv/base/cpymem-2.c: Ditto.
* gcc.target/riscv/rvv/base/cpymem-3.c: Ditto.
* gcc.target/riscv/rvv/base/movmem-1.c: Ditto.
* gcc.target/riscv/rvv/base/pr115068.c: Ditto.
* gcc.target/riscv/rvv/base/setmem-1.c: Ditto.
* gcc.target/riscv/rvv/base/setmem-2.c: Ditto.
* gcc.target/riscv/rvv/base/setmem-3.c: Ditto.
* gcc.target/riscv/rvv/base/vwaddsub-1.c: Ditto.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
6 months agotestsuite: RISC-V: Add effective target for E ABI variant
Dimitar Dimitrov [Thu, 12 Dec 2024 18:22:59 +0000 (20:22 +0200)] 
testsuite: RISC-V: Add effective target for E ABI variant

Add new effective target check for either ILP32E or ILP64E ABI variants.

Initial implementation only checks for RV32E or RV64E ISA, which in turn
implies that ILP32E/ILP64E ABI is used.  The RV32I+ILP32E and
RV64I+ILP64E combinations are not yet caught by the check, but they
do not seem to be widely used currently.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_riscv_abi_e):
New procedure.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
6 months agoDocument unsigned constants in intrinsic modules.
Thomas Koenig [Tue, 7 Jan 2025 14:23:29 +0000 (15:23 +0100)] 
Document unsigned constants in intrinsic modules.

gcc/fortran/ChangeLog:

* intrinsic.texi (ISO_FORTRAN_ENV):  Also mention INT8 in the
text. Document UINT8, UINT16, UINT32 and UINT64.
(ISO_C_BINDING): New table for unsigned KIND numbers.

6 months agoAArch64: Switch off early scheduling
Wilco Dijkstra [Fri, 1 Nov 2024 14:40:26 +0000 (14:40 +0000)] 
AArch64: Switch off early scheduling

The early scheduler takes up ~33% of the total build time, however it doesn't
provide a meaningful performance gain.  This is partly because modern OoO cores
need far less scheduling, partly because the scheduler tends to create many
unnecessary spills by increasing register pressure.  Building applications
56% faster is far more useful than ~0.1% improvement on SPEC, so switch off
early scheduling on AArch64.  Codesize reduces by ~0.2%.

Fix various tests that depend on scheduling by explicitly adding -fschedule-insns.

gcc:
* common/config/aarch64/aarch64-common.cc: Switch off fschedule_insns.

gcc/testsuite:
* gcc.dg/guality/pr36728-3.c: Remove XFAIL.
* gcc.dg/guality/pr68860-1.c: Likewise.
* gcc.dg/guality/pr68860-2.c: Likewise.
* gcc.target/aarch64/ldp_aligned.c: Fix test.
* gcc.target/aarch64/ldp_always.c: Likewise.
* gcc.target/aarch64/ldp_stp_10.c: Add -fschedule-insns.
* gcc.target/aarch64/ldp_stp_12.c: Likewise.
* gcc.target/aarch64/ldp_stp_13.c: Remove test.
* gcc.target/aarch64/ldp_stp_21.c: Add -fschedule-insns.
* gcc.target/aarch64/ldp_stp_8.c: Likewise.
* gcc.target/aarch64/ldp_vec_v2sf.c: Likewise.
* gcc.target/aarch64/ldp_vec_v2si.c: Likewise.
* gcc.target/aarch64/test_frame_16.c: Fix test.
* gcc.target/aarch64/sve/vcond_12.c: Add -fschedule-insns.
* gcc.target/aarch64/sve/acle/general/ldff1_3.c: Likewise.

6 months agoAArch64: Block combine_and_move from creating FP literal loads
Wilco Dijkstra [Fri, 1 Nov 2024 14:44:56 +0000 (14:44 +0000)] 
AArch64: Block combine_and_move from creating FP literal loads

The IRA combine_and_move pass runs if the scheduler is disabled and aggressively
combines moves.  The movsf/df patterns allow all FP immediates since they rely
on a split pattern.  However splits do not happen during IRA, so the result is
extra literal loads.  To avoid this, split early during expand and block
creation of FP immediates that need this split.  Mark a few testcases that
rely on late splitting as xfail.

double f(void) { return 128.0; }

-O2 -fno-schedule-insns gives:

adrp x0, .LC0
ldr d0, [x0, #:lo12:.LC0]
ret

After patch:

mov x0, 4638707616191610880
fmov d0, x0
ret

Passes bootstrap & regress, OK for commit?

gcc:
* config/aarch64/aarch64.md (movhf_aarch64): Use aarch64_valid_fp_move.
(movsf_aarch64): Likewise.
(movdf_aarch64): Likewise.
* config/aarch64/aarch64.cc (aarch64_valid_fp_move): New function.
* config/aarch64/aarch64-protos.h (aarch64_valid_fp_move): Likewise.

gcc/testsuite:
* gcc.target/aarch64/dbl_mov_immediate_1.c: Add xfail for -0.0.
* gcc.target/aarch64/fmul_scvtf_1.c: Fixup test cases, add xfail,
reduce duplication.

6 months agolibgomp.texi: Minor update to omp_get_num_devices/omp_get_initial_device
Tobias Burnus [Tue, 7 Jan 2025 15:43:30 +0000 (16:43 +0100)] 
libgomp.texi: Minor update to omp_get_num_devices/omp_get_initial_device

libgomp/ChangeLog:

* libgomp.texi (OpenMP 6.0): Fix typo.
(omp_get_default_device): Update the wording as the value
returned by omp_get_initial_device is now ambiguous.
(omp_get_num_devices): Minor wording tweak.
(omp_get_initial_device): Note that the function may also
return omp_initial_device since OpenMP 6.

6 months agoOnly apply adjust_args in OpenMP dispatch if variant substitution occurs
Paul-Antoine Arras [Mon, 6 Jan 2025 16:00:10 +0000 (17:00 +0100)] 
Only apply adjust_args in OpenMP dispatch if variant substitution occurs

This is a followup to
084ea8ad584 OpenMP: middle-end support for dispatch + adjust_args.

This patch fixes a bug that caused arguments in an OpenMP dispatch call to be
modified even when no variant substitution occurred.

gcc/ChangeLog:

* gimplify.cc (gimplify_call_expr): Create variable
variant_substituted_p to control whether adjust_args applies.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/adjust-args-4.c: New test.

6 months agoperform affine fold to unsigned on non address expressions. [PR114932]
Tamar Christina [Mon, 6 Jan 2025 17:52:14 +0000 (17:52 +0000)] 
perform affine fold to unsigned on non address expressions. [PR114932]

When the patch for PR114074 was applied we saw a good boost in exchange2.

This boost was partially caused by a simplification of the addressing modes.
With the patch applied IV opts saw the following form for the base addressing;

  Base: (integer(kind=4) *) &block + ((sizetype) ((unsigned long) l0_19(D) *
324) + 36)

vs what we normally get:

  Base: (integer(kind=4) *) &block + ((sizetype) ((integer(kind=8)) l0_19(D)
* 81) + 9) * 4

This is because the patch promoted multiplies where one operand is a constant
from a signed multiply to an unsigned one, to attempt to fold away the constant.

This patch attempts the same but due to the various problems with SCEV and
niters not being able to analyze the resulting forms (i.e. PR114322) we can't
do it during SCEV or in the general form like in fold-const like extract_muldiv
attempts.

Instead this applies the simplification during IVopts initialization when we
create the IV. This allows IV opts to see the simplified form without
influencing the rest of the compiler.

as mentioned in PR114074 it would be good to fix the missed optimization in the
other passes so we can perform this in general.

The reason this has a big impact on Fortran code is that Fortran doesn't seem to
have unsigned integer types.  As such all it's addressing are created with
signed types and folding does not happen on them due to the possible overflow.

concretely on AArch64 this changes the results from generation:

        mov     x27, -108
        mov     x24, -72
        mov     x23, -36
        add     x21, x1, x0, lsl 2
        add     x19, x20, x22
.L5:
        add     x0, x22, x19
        add     x19, x19, 324
        ldr     d1, [x0, x27]
        add     v1.2s, v1.2s, v15.2s
        str     d1, [x20, 216]
        ldr     d0, [x0, x24]
        add     v0.2s, v0.2s, v15.2s
        str     d0, [x20, 252]
        ldr     d31, [x0, x23]
        add     v31.2s, v31.2s, v15.2s
        str     d31, [x20, 288]
        bl      digits_20_
        cmp     x21, x19
        bne     .L5

into:

.L5:
        ldr     d1, [x19, -108]
        add     v1.2s, v1.2s, v15.2s
        str     d1, [x20, 216]
        ldr     d0, [x19, -72]
        add     v0.2s, v0.2s, v15.2s
        str     d0, [x20, 252]
        ldr     d31, [x19, -36]
        add     x19, x19, 324
        add     v31.2s, v31.2s, v15.2s
        str     d31, [x20, 288]
        bl      digits_20_
        cmp     x21, x19
        bne     .L5

The two patches together results in a 10% performance increase in exchange2 in
SPECCPU 2017 and a 4% reduction in binary size and a 5% improvement in compile
time. There's also a 5% performance improvement in fotonik3d and similar
reduction in binary size.

The patch folds every IV to unsigned to canonicalize them.  At the end of the
pass we match.pd will then remove unneeded conversions.

Note that we cannot force everything to unsigned, IVops requires that array
address expressions remain as such.  Folding them results in them becoming
pointer expressions for which some optimizations in IVopts do not run.

gcc/ChangeLog:

PR tree-optimization/114932
* tree-ssa-loop-ivopts.cc (alloc_iv): Perform affine unsigned fold.

gcc/testsuite/ChangeLog:

PR tree-optimization/114932
* gcc.dg/tree-ssa/pr64705.c: Update dump file scan.
* gcc.target/i386/pr115462.c: The testcase shares 3 IVs which calculates
the same thing but with a slightly different increment offset.  The test
checks for 3 complex addressing loads, one for each IV.  But with this
change they now all share one IV.  That is the loop now only has one
complex addressing.  This is ultimately driven by the backend costing
and the current costing says this is preferred so updating the testcase.
* gfortran.dg/addressing-modes_1.f90: New test.

6 months agocfgexpand: Handle integral vector types and constructors for scope conflicts [PR105769]
Andrew Pinski [Sat, 16 Nov 2024 04:22:04 +0000 (20:22 -0800)] 
cfgexpand: Handle integral vector types and constructors for scope conflicts [PR105769]

This is an expansion of the last patch to also track pointers via vector types and the
constructor that are used with vector types.
In this case we had:
```
_15 = (long unsigned int) &bias;
_10 = (long unsigned int) &cov_jn;
_12 = {_10, _15};
...

MEM[(struct vec *)&cov_jn] ={v} {CLOBBER(bob)};
bias ={v} {CLOBBER(bob)};
MEM[(struct function *)&D.6156] ={v} {CLOBBER(bob)};

...
MEM <vector(2) long unsigned int> [(void *)&D.6172 + 32B] = _12;
MEM[(struct function *)&D.6157] ={v} {CLOBBER(bob)};
```

Anyways tracking the pointers via vector types to say they are alive
at the point where the store of the vector happens fixes the bug by saying
it is alive at the same time as another variable is alive.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/105769

gcc/ChangeLog:

* cfgexpand.cc (vars_ssa_cache::operator()): For constructors
walk over the elements.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr105769-1.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
6 months agocfgexpand: Rewrite add_scope_conflicts_2 to use cache and look back further [PR111422]
Andrew Pinski [Sat, 16 Nov 2024 04:22:03 +0000 (20:22 -0800)] 
cfgexpand: Rewrite add_scope_conflicts_2 to use cache and look back further [PR111422]

After fixing loop-im to do the correct overflow rewriting
for pointer types too. We end up with code like:
```
_9 = (unsigned long) &g;
_84 = _9 + 18446744073709551615;
_11 = _42 + _84;
_44 = (signed char *) _11;
...
*_44 = 10;
g ={v} {CLOBBER(eos)};
...
n[0] = &f;
*_44 = 8;
g ={v} {CLOBBER(eos)};
```

Which was not being recongized by the scope conflicts code.
This was because it only handled one level walk backs rather than multiple ones.
This fixes the issue by having a cache which records all references to addresses
of stack variables.

Unlike the previous patch, this only records and looks at addresses of stack variables.
The cache uses a bitmap and uses the index as the bit to look at.

PR middle-end/117426
PR middle-end/111422
gcc/ChangeLog:

* cfgexpand.cc (struct vars_ssa_cache): New class.
(vars_ssa_cache::vars_ssa_cache): New constructor.
(vars_ssa_cache::~vars_ssa_cache): New deconstructor.
(vars_ssa_cache::create): New method.
(vars_ssa_cache::exists): New method.
(vars_ssa_cache::add_one): New method.
(vars_ssa_cache::update): New method.
(vars_ssa_cache::dump): New method.
(add_scope_conflicts_2): Factor mostly out to
vars_ssa_cache::operator(). New cache argument.
Walk the bitmap cache for the stack variables addresses.
(vars_ssa_cache::operator()): New method factored out from
add_scope_conflicts_2. Rewrite to be a full walk of all operands
and use a worklist.
(add_scope_conflicts_1): Add cache new argument for the addr cache.
Just call add_scope_conflicts_2 for the phi result instead of calling
for the uses and don't call walk_stmt_load_store_addr_ops for phis.
Update call to add_scope_conflicts_2 to add cache argument.
(add_scope_conflicts): Add cache argument and update calls to
add_scope_conflicts_1.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr117426-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
6 months agocfgexpand: Factor out getting the stack decl index
Andrew Pinski [Sat, 16 Nov 2024 04:22:02 +0000 (20:22 -0800)] 
cfgexpand: Factor out getting the stack decl index

This is the first patch in improving this code.
Since there are a few places which get the index and they
check the same thing, let's factor that out into one function.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* cfgexpand.cc (INVALID_STACK_INDEX): New defined.
(decl_stack_index): New function.
(visit_op): Use decl_stack_index.
(visit_conflict): Likewise.
(add_scope_conflicts_1): Likewise.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
6 months ago[PR testsuite/118055] Trivial testsuite adjustment for m68k target
Jeff Law [Tue, 7 Jan 2025 14:43:19 +0000 (07:43 -0700)] 
[PR testsuite/118055] Trivial testsuite adjustment for m68k target

After a bit of a prod from Hans...

Make the obvious change to these tests to get them passing again on m68k.

PR testsuite/118055

gcc/testsuite

* gcc.dg/tree-ssa/pr83403-1.c: Add m68k*-*-* to targets needing
additional arguments for peeling.
* gcc.dg/tree-ssa/pr83403-2.c: Similarly.

6 months agortl-optimization/118298 - constant iteration loops and #pragma unroll
Richard Biener [Tue, 7 Jan 2025 12:18:27 +0000 (13:18 +0100)] 
rtl-optimization/118298 - constant iteration loops and #pragma unroll

When the RTL unroller handles constant iteration loops it bails out
prematurely when heuristics wouldn't apply any unrolling before
checking #pragma unroll.

PR rtl-optimization/118298
* loop-unroll.cc (decide_unroll_constant_iterations): Honor
loop->unroll even if the loop is too big for heuristics.

6 months agoFixup convert-dfp*.c
Richard Biener [Tue, 7 Jan 2025 14:07:12 +0000 (15:07 +0100)] 
Fixup convert-dfp*.c

The testcases use -save-temps which doesn't play nice with -flto
and multilib testing resulting in spurious UNRESOLVED like

/usr/lib64/gcc/x86_64-suse-linux/14/../../../../x86_64-suse-linux/bin/ld: i386:x86-64 architecture of input file `./convert-dfp-2.ltrans0.ltrans.o' is incompatible with i386 output

The following skips the testcases when using -flto.

* gcc.dg/torture/convert-dfp-2.c: Skip with -flto.
* gcc.dg/torture/convert-dfp.c: Likewise.

6 months agoRISC-V: Add missing dg-runtest to run the testcase under gcc.target/riscv/rvv/
Tsung Chun Lin [Tue, 7 Jan 2025 14:07:23 +0000 (07:07 -0700)] 
RISC-V: Add missing dg-runtest to run the testcase under gcc.target/riscv/rvv/

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/rvv.exp: Add dg-runtest to run the
testcase under gcc.target/riscv/rvv/.

6 months agoUpdate copyright years.
Marc Poulhiès [Thu, 2 Jan 2025 14:55:29 +0000 (15:55 +0100)] 
Update copyright years.

6 months agoada: Adjust pragma obsolescent message
Marc Poulhiès [Mon, 6 Jan 2025 09:59:10 +0000 (10:59 +0100)] 
ada: Adjust pragma obsolescent message

Do not mention an explicit version.

gcc/ada/ChangeLog:

* libgnat/a-calcon.ads: Adjust.
* libgnat/a-calend.ads: Adjust.

6 months agoada: Drop g-cpp* units not needed by the compiler
Alexandre Oliva [Wed, 11 Dec 2024 13:16:58 +0000 (10:16 -0300)] 
ada: Drop g-cpp* units not needed by the compiler

Having moved __gnat_convert_caught_object to g-cstyin.o, we can drop
other g-cpp* units that are now needed by programs that actually use
their APIs to get more information about C++ exceptions and type_info
objects.

gcc/ada/ChangeLog:

* gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS):
Drop g-cpp, g-cppexc and g-cppstd.

6 months agoada: Do not create temporaries for initialization statements
Eric Botcazou [Tue, 10 Dec 2024 09:24:47 +0000 (10:24 +0100)] 
ada: Do not create temporaries for initialization statements

Assignment statements marked with the No_Ctrl_Actions or No_Finalize_Actions
flag are initialization statements and, therefore, no temporaries are needed
to hold the value of the right-hand side for them.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (Call_to_gnu): Always use the return slot
optimization if the parent node is an initialization statement.
(gnat_to_gnu) <N_Assignment_Statement>: Build an INIT_EXPR instead
of a MODIFY_EXPR if this is an initialization statement.

6 months agoada: Remove unused AST flag Address_Warning_Posted
Piotr Trojanek [Mon, 23 Dec 2024 09:49:11 +0000 (10:49 +0100)] 
ada: Remove unused AST flag Address_Warning_Posted

Flag Address_Warning_Posted was only read and never written, so it can be
safely removed.

gcc/ada/ChangeLog:

* gen_il-fields.ads (Opt_Field_Enum): Remove flag.
* gen_il-gen-gen_nodes.adb (N_Attribute_Definition_Clause): Remove
field.
* sem_ch13.adb (Validate_Address_Clauses): Remove read of the flag.
* sinfo.ads (Address_Warning_Posted): Remove flag description.

6 months agoada: Do not raise exceptions from Exp_Aggr.Packed_Array_Aggregate_Handled
Eric Botcazou [Fri, 20 Dec 2024 15:49:50 +0000 (16:49 +0100)] 
ada: Do not raise exceptions from Exp_Aggr.Packed_Array_Aggregate_Handled

An exception is now raised during bootstrap and this causes compatibility
issues with older compilers.

gcc/ada/ChangeLog:

* exp_aggr.adb (Packed_Array_Aggregate_Handled): Remove declaration
and handler for Not_Handled local exception. Check the return value
of Get_Component_Val instead.
(Get_Component_Val): Return No_Uint instead of raising Not_Handled.

6 months agoada: Cleanup preanalysis of static expressions (part 2)
Javier Miranda [Thu, 19 Dec 2024 10:41:59 +0000 (10:41 +0000)] 
ada: Cleanup preanalysis of static expressions (part 2)

According to RM 13.14(8/4), a static expression in an aspect specification
does not cause freezing; however, the frontend performs many calls to
Preanalyze_Spec_Expression made during the analysis of aspects. This
patch, suggested by Eric Botcazou, takes care of this additional code
cleanup which requires also replacing many occurrences of the global
variable In_Spec_Expression by calls to Preanalysis_Active.

gcc/ada/ChangeLog:

* exp_util.adb (Insert_Actions): Document behavior under strict
preanalysis.
* sem.ads (In_Strict_Preanalysis): New subprogram.
(Preanalysis_Active): Replace 'and' operator by 'and then'.
* sem.adb (In_Strict_Preanalysis): Ditto.
* sem_attr.adb (Check_Dereference): Replace In_Spec_Expression
occurrence by call to Preanalysis_Active, and document it.
(Resolve_Attribute [Atribute_Access]): Ditto.
(Eval_Attribute): No evaluation under strict preanalysis.
(Validate_Static_Object_Name): No action under strict preanalysis.
* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Replace
calls to Preanalyze_Spec_Expression by calls to Preanalyze_And_Resolve.
(Check_Aspect_At_Freeze_Point): Ditto.
(Resolve_Aspect_Expressions [Dynamic/Static/Predicate aspects]): Code
cleanup adjusting the code to emulate Preanalyze_And_Resolve, instead
of Preanalyze_Spec_Expression.
(Resolve_Aspect_Expressions [CPU/Interrupt_Priority/Priority/
Storage_Size aspects]): Replace calls to Preanalyze_Spec_Expression
by call to Preanalyze_And _Resolve.
* sem_ch3.adb (Analyze_Object_Declaration): Replace In_Spec_Expression
occurrence by call to Preanalysis_Active.
(Find_Type_Of_Object): Add documentation.
* sem_ch4.adb (Analyze_Case_Expression): Replace In_Spec_Expression
occurrence by call to Preanalysis_Active.
* sem_ch6.adb (Analyze_Expression_Function): Minor code reorganization
moving the code preanalyzing the expression after the new body has
been inserted in the tree to ensure that its Parent attribute is
available for preanalysis.
* sem_cat.adb (Validate_Static_Object_Name): No action under strict
preanalysis.
* sem_elab.adb (Check_For_Eliminated_Subprogram): Replace In_Spec_Expression
occurrence by call to Preanalysis_Active.
* sem_eval.adb (Eval_Intrinsic_Call [Name_Enclosing_Entity]): Ditto.
* sem_elim.adb (Check_For_Eliminated_Subprogram): Ditto.
* sem_res.adb (Resolve_Entity_Name): Ditto.

6 months agoada: Fix constants overlayed by variables
Piotr Trojanek [Thu, 19 Dec 2024 23:13:57 +0000 (00:13 +0100)] 
ada: Fix constants overlayed by variables

Code cleanup suggested by GNATcheck rule Constant_Overlays.

gcc/ada/ChangeLog:

* repinfo-input.adb (Decode_Name, Read_Name_With_Prefix): Use constant
overlay with pragma Import.

6 months agoada: Improve protection against wrong use from GDB
Piotr Trojanek [Thu, 19 Dec 2024 23:09:15 +0000 (00:09 +0100)] 
ada: Improve protection against wrong use from GDB

A code cleanup in routine intended to be used from DGB, suggested by running
GNATcheck rule Boolean_Negations. However, this code can be tuned to protect
against more illegal uses.

gcc/ada/ChangeLog:

* exp_disp.adb (Write_DT): Add guards that prevent crashes on illegal
node numbers.

6 months agoada: Fix violations of GNAT-specific GNATcheck rules
Piotr Trojanek [Thu, 19 Dec 2024 23:07:23 +0000 (00:07 +0100)] 
ada: Fix violations of GNAT-specific GNATcheck rules

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* diagnostics-pretty_emitter.adb (Get_Last_Line_Char): Fix whitespace.
* sem_aggr.adb (Resolve_Array_Aggregate): Fix style.

6 months agoada: Remove dead code in detection of null record definitions
Piotr Trojanek [Thu, 19 Dec 2024 14:32:56 +0000 (15:32 +0100)] 
ada: Remove dead code in detection of null record definitions

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

* sem_util.adb (Is_Null_Record_Definition): Remove check for
Component_List being present after using it; replace check for
component item being a component declaration with an assertion;
fix style in comment.

6 months agoada: Fix abort deferral for finally parts
Ronan Desplanques [Thu, 19 Dec 2024 10:10:12 +0000 (11:10 +0100)] 
ada: Fix abort deferral for finally parts

This patch fixes two problems with how abort was deferred in finally
parts. First, calls to runtime subprograms are now omitted when
aborting is disallowed by active restrictions. Second, Abort_Undefer is
now correctly called when the finally part propagates an exception.

gcc/ada/ChangeLog:

* exp_ch11.adb (Expand_N_Handled_Sequence_Of_Statements): Fix abort
deferral.

6 months agoada: Improved checking of uses of package renamings
Steve Baird [Tue, 17 Dec 2024 21:27:04 +0000 (13:27 -0800)] 
ada: Improved checking of uses of package renamings

In some cases, the RM 8.5.1(3.1) legality rule about uses of renamings of
limited views of packages was implemented incorrectly, resulting in rejecting
legal uses.

gcc/ada/ChangeLog:

* gen_il-fields.ads: add new Renames_Limited_View field.
* gen_il-gen-gen_entities.adb: add Renames_Limited_View flag for
packages.
* einfo.ads: add comment documenting Renames_Limited_View flag.
* sem_ch8.adb (Analyze_Package_Renaming): Set new Renames_Limited_View
flag. Test new Renames_Limited_View flag instead of calling
Has_Limited_With. If Has_Limited_With is True, that just means
that somebody, sometime during this compilation needed to
reference the limited view of the package; so that function
returns True too often to be used here.
(Find_Expanded_Name): Test new Renames_Limited_View flag instead of
calling Has_Limited_With.

6 months agoada: Remove flag Is_Inherited_Pragma which is only set and never used
Piotr Trojanek [Tue, 30 Jan 2024 00:10:17 +0000 (01:10 +0100)] 
ada: Remove flag Is_Inherited_Pragma which is only set and never used

Code cleanup; behavior is unaffected. Flag Is_Inherited_Pragma is only set in
GNAT, but is not actually used, neither by the compiler nor by any backend.

gcc/ada/ChangeLog:

* contracts.adb (Inherit_Pragma): Don't set flag Is_Inherited_Pragma.
* gen_il-fields.ads (Opt_Field_Enum): Remove field identifier.
* gen_il-gen-gen_nodes.adb (N_Pragma): Remove field from node.
* sinfo.ads (Is_Inherited_Pragma): Remove field description.
(N_Pragma): Remove field reference.

6 months agoada: Avoid conversion from String to Name_Id at runtime
Piotr Trojanek [Tue, 26 Mar 2024 14:05:47 +0000 (15:05 +0100)] 
ada: Avoid conversion from String to Name_Id at runtime

Code cleanup.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Attribute): Replace runtime conversion
with existing constant.

6 months agoada: Untangle check for restriction No_Implementation_Attributes
Piotr Trojanek [Tue, 26 Mar 2024 15:52:08 +0000 (16:52 +0100)] 
ada: Untangle check for restriction No_Implementation_Attributes

Code cleanup; given that no attribute is both defined by Ada 83 and specific to
GNAT, the semantics is unaffected.

gcc/ada/ChangeLog:

* sem_attr.adb (Analyze_Attribute): Simplify logic.

6 months agoada: Handle attributes related to Ada 2012 iterators as internal
Piotr Trojanek [Tue, 26 Mar 2024 15:23:41 +0000 (16:23 +0100)] 
ada: Handle attributes related to Ada 2012 iterators as internal

Use existing machinery for internal attributes to handle attributes
related to Ada 2012 iterators. All these attributes exist exclusively
as a mean to delay processing.

Code cleanup. The only change in behavior is the wording of error
emitted when one of the internal attributes appears in source code:
from "illegal attribute" (which used to be emitted in the analysis)
to "unrecognized attribute (which is emitted by the parser).

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): Remove explicit
handling of attributes related to Ada 2012 iterators.
* sem_attr.adb (Analyze_Attribute, Eval_Attribute): Likewise;
move attribute Reduce according to alphabetic order.
* snames.adb-tmpl (Get_Attribute_Id): Add support for new internal
attributes.
* snames.ads-tmpl: Recognize names of new internal attributes.
(Attribute_Id): Recognize new internal attributes.
(Internal_Attribute_Id): Likewise.
(Is_Internal_Attribute_Name): Avoid duplication in comment.

6 months agoada: Remove unnecessary qualifiers for First/Next list operations
Piotr Trojanek [Thu, 2 Mar 2023 21:43:12 +0000 (22:43 +0100)] 
ada: Remove unnecessary qualifiers for First/Next list operations

Code cleanup related to work on expression functions for GNATprove
(which require accessibility checks even when they are not expanded
and thus have no explicit return statements).

gcc/ada/ChangeLog:

* accessibility.adb (First_Selector): Remove redundant and locally
inconsistent parenthesis.
(Check_Return_Construct_Accessibility): Remove qualifier from list
operation.
* sem_util.adb (Is_Prim_Of_Abst_Type_With_Nonstatic_CW_Pre_Post):
Likewise.

6 months agoada: Fix internal error on container aggregate for bounded vectors
Eric Botcazou [Wed, 18 Dec 2024 09:16:15 +0000 (10:16 +0100)] 
ada: Fix internal error on container aggregate for bounded vectors

The problem is that we analyze references to an object before the actual
subtype of the object is established, thus creating a type mismatch that
is flagged by the code generator.

gcc/ada/ChangeLog:

* exp_ch7.ads (Store_After_Actions_In_Scope_Without_Analysis): New
procedure declaration.
* exp_ch7.adb (Store_New_Actions_In_Scope): New procedure.
(Store_Actions_In_Scope): Call Store_New_Actions_In_Scope when the
target list is empty.
(Store_After_Actions_In_Scope_Without_Analysis): New procedure body.
* exp_aggr.adb (Expand_Container_Aggregate): For a declaration that
is wrapped in a transient scope, also defer the analysis of the new
code until after the declaration is analyzed.

6 months agoada: Add guard to System.Val_Real.Large_Powfive against pathological input
Eric Botcazou [Tue, 17 Dec 2024 19:00:38 +0000 (20:00 +0100)] 
ada: Add guard to System.Val_Real.Large_Powfive against pathological input

There is no need to keep multiplying the result once it saturates to +Inf.

gcc/ada/ChangeLog:

* libgnat/s-powflt.ads (Maxpow_Exact): Minor comment fix.
* libgnat/s-powlfl.ads (Maxpow_Exact): Likewise.
* libgnat/s-powllf.ads (Maxpow_Exact): Likewise.
* libgnat/s-valrea.adb (Large_Powfive) [1 parameter]: Exit the loop
as soon as the result saturates to +Inf.
(Large_Powfive) [2 parameters]: Likewise.

6 months agoada: Drop vxworks-smp-ppc-link.spec
Alexandre Oliva [Wed, 16 Aug 2023 01:07:27 +0000 (22:07 -0300)] 
ada: Drop vxworks-smp-ppc-link.spec

Adding -msmp to linker options in system-vxworks-ppc-rtp-smp.ads
obviated vxworks-smp-ppc-link.spec.  Drop it.

gcc/ada/ChangeLog:

* libgnat/system-vxworks-ppc-rtp-smp.ads: Drop
--specs=vxworks-ppc-link.spec from Linker_Options.
* vxworks-smp-ppc-link.spec: Delete.

6 months agoada: Add "finally" GNAT extension
Ronan Desplanques [Tue, 17 Dec 2024 09:43:56 +0000 (10:43 +0100)] 
ada: Add "finally" GNAT extension

This patch adds a new reserved word, "finally", and accompanying new
syntax that's similar to the Java equivalent.

gcc/ada/ChangeLog:

* atree.adb (Parent_Or_List_Containing): New function.
* atree.ads (Parent_Or_List_Containing): Likewise.
* gen_il-fields.ads: Add new field.
* gen_il-gen-gen_nodes.adb (Gen_Nodes): Extend handled sequence of
statements node.
* par-ch11.adb (P_Handled_Sequence_Of_Statements, P_Exception_Handler):
Add new syntactic construct.
* par-ch5.adb (P_Sequence_Of_Statements): Likewise.
* par.adb: Likewise.
* par-util.adb (Check_Future_Keyword): Warn that "finally" becomes a
reserved word with extensions.
* scans.adb (Initialize_Ada_Keywords): Add new reserved word.
* snames.adb-tmpl: Likewise.
* snames.ads-tmpl: Likewise.
* scans.ads: Likewise.
* sem_ch11.adb (Analyze_Handled_Statements): Adapt to new node field.
* sem_ch5.adb (Analyze_Exit_Statement): Add legality check.
(Analyze_Goto_Statement): Likewise.
* sem_ch6.adb (Analyze_Return_Statement): Likewise.
* sinfo-utils.adb (Lowest_Common_Ancestor, Destroy_Element): New
subprograms.
* sinfo-utils.ads (Lowest_Common_Ancestor): New function.
* sinfo.ads: Add documentation for new field.
* xsnamest.adb: Fix typo in comment.
* doc/gnat_rm/gnat_language_extensions.rst: Document new extension.
* warnsw.adb: Add new option.
* warnsw.ads: Likewise.
* exp_ch11.adb (Expand_N_Handled_Sequence_Of_Statements): Add abort
deferral to finally part.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
* gcc-interface/trans.cc (Handled_Sequence_Of_Statements_to_gnu):
Handle finally statements.

6 months agoada: Elide the copy for bit-packed aggregates in (safe) assignments
Eric Botcazou [Tue, 17 Dec 2024 10:20:03 +0000 (11:20 +0100)] 
ada: Elide the copy for bit-packed aggregates in (safe) assignments

The in-place expansion has been historically disabled for them, but there
does not seem to be any good reason left for this.

gcc/ada/ChangeLog:

* exp_aggr.adb (Expand_Array_Aggregate): Do not exclude aggregates
of bit-packed array types in assignments from in-place expansion.

6 months agoada: Reject references to attribute Result in Exceptional_Cases
Piotr Trojanek [Mon, 16 Dec 2024 13:36:13 +0000 (14:36 +0100)] 
ada: Reject references to attribute Result in Exceptional_Cases

Functions with aspect Side_Effects should not reference attribute Result in
consequences of their aspect Exceptional_Cases.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Exceptional_Cases_In_Decl_Part): Reject
references to attribute Result.

6 months agoada: Move checks for consequences of Exceptional_Cases to GNAT
Piotr Trojanek [Mon, 16 Dec 2024 13:15:57 +0000 (14:15 +0100)] 
ada: Move checks for consequences of Exceptional_Cases to GNAT

Previously checks for consequence expressions of Exceptional_Cases aspects were
done in GNATprove backend. However, we can do them in the frontend, where they
will apply to all subprograms, regardless of the SPARK_Mode aspect.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Exceptional_Cases_In_Decl_Part): Move check
from GNATprove backend to GNAT frontend.

6 months agoada: Fix comments about Subprogram_Variant and Exceptional_Cases
Piotr Trojanek [Mon, 16 Dec 2024 12:52:43 +0000 (13:52 +0100)] 
ada: Fix comments about Subprogram_Variant and Exceptional_Cases

The comment about Subprogram_Variant was outdated after more types have been
allowed by the corresponding SPARK RM rule; the comment about Exceptional_Cases
was incorrect, after being copy-pasted.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Exceptional_Contract, Analyze_Variant): Fix
comments.

6 months agoada: Put_Image spec incorrectly ignored for Fixed_Point_Type'Base'Image call.
Steve Baird [Fri, 13 Dec 2024 01:06:00 +0000 (17:06 -0800)] 
ada: Put_Image spec incorrectly ignored for Fixed_Point_Type'Base'Image call.

If a Put_Image aspect specification (introduced in Ada 2022) is given for a
fixed point type Fx, then in some cases a call to Fx'Base'Image would
incorrectly ignore the aspect specification and would instead return the
pre-Ada2022 version of the image. However, a call to Fx'Image would do the
right thing.

gcc/ada/ChangeLog:

* exp_put_image.adb (Image_Should_Call_Put_Image): Cope with the case
where the attribute prefix for an Image attribute reference
denotes an Itype constructed for a fixed point type. Calling
Has_Aspect with such an Itype misses applicable aspect
specifications; we need to look on the right list. This comes up
if the prefix of the attribute reference is
Some_Fixed_Point_Type'Base.

6 months agoada: Error on instantiation with defaulted formal type referencing other formal type
Gary Dismukes [Fri, 13 Dec 2024 23:36:05 +0000 (23:36 +0000)] 
ada: Error on instantiation with defaulted formal type referencing other formal type

The compiler wasn't accounting for default subtypes on generic formal types
that reference other formal types of the same generic, leading to errors
about invalid subtypes. Several other problems that could lead to blowups
or incorrect errors were noticed through testing related cases and fixed
along the way.

gcc/ada/ChangeLog:

* sem_ch12.adb (Analyze_One_Association): In the case of a formal type
that has a Default_Subtype_Mark that does not have its Entity field set,
this means the default refers to another formal type of the same generic
formal part, so locate the matching subtype in the Result_Renamings and
set Match's Entity to that subtype prior to the call to Instantiate_Type.
(Validate_Formal_TypeDefault.Reference_Formal): Add test of Entity being
Present, to prevent blowups on End_Label ids (which don't have Entity set).
(Validate_Formal_Type_Default.Validate_Derived_Type_Default): Apply
Base_Type to Formal.
(Validate_Formal_Type_Default): Guard interface-related semantic checks
with a test of Is_Tagged_Type.

6 months agoada: Use the syntax of Ada 2012 if-expression in -gnatR3 output
Eric Botcazou [Sun, 15 Dec 2024 15:37:57 +0000 (16:37 +0100)] 
ada: Use the syntax of Ada 2012 if-expression in -gnatR3 output

This uses the syntax of Ada 2012 if-expression in the output produced by the
-gnatR3 switch for dynamic expressions.

gcc/ada/ChangeLog:

* repinfo.adb (List_GCC_Expression.Print_Expr) <Cond_Expr>: Do not
output the final "end".

6 months agoada: Preserve Warning_Doc_Switch in gnatprove invocation
Johannes Kanig [Tue, 3 Dec 2024 10:53:28 +0000 (19:53 +0900)] 
ada: Preserve Warning_Doc_Switch in gnatprove invocation

When invoked by gnat2why, the Warning_Doc_Switch was unintenionally
reset.

gcc/ada/ChangeLog:

* gnat1drv.adb: (SPARK_Library_Warning): preserve Warning_Doc_Switch

6 months agoada: Restrict previous change made to expansion of allocators
Eric Botcazou [Mon, 16 Dec 2024 07:59:26 +0000 (08:59 +0100)] 
ada: Restrict previous change made to expansion of allocators

There is no need to build a cleanup if exceptions cannot be propagated.

gcc/ada/ChangeLog:

* exp_ch4.adb (Expand_Allocator_Expression): Do not build a cleanup
if restriction No_Exception_Propagation is active.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.

6 months agoFortran: Ensure deep copy of allocatable components in cylic types [PR114612]
Andre Vehreschild [Fri, 13 Dec 2024 11:07:01 +0000 (12:07 +0100)] 
Fortran: Ensure deep copy of allocatable components in cylic types [PR114612]

gcc/fortran/ChangeLog:

PR fortran/114612

* trans-array.cc (structure_alloc_comps): Ensure deep copy is
also done for types having cycles.

gcc/testsuite/ChangeLog:

* gfortran.dg/alloc_comp_deep_copy_4.f03: New test.

6 months agoLoongArch: Optimize initializing fp resgister to zero
Deng Jianbo [Tue, 31 Dec 2024 11:33:23 +0000 (19:33 +0800)] 
LoongArch: Optimize initializing fp resgister to zero

In LoongArch, currently uses instruction movgr2fr.{d|w} to move zero
from fixed-point register to floating-pointer regsiter for initializing
fp register to zero. When LSX or LASX is enabled, we can use instruction
vxor.v which has lower latency than instruction movgr2fr.{d|w} to set fp
register to zero directly.

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_output_move):
Optimize instructions for initializing fp regsiter to zero.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/mov-zero-1.c: New test.
* gcc.target/loongarch/mov-zero-2.c: New test.

6 months ago[PR modula2/118010, modula2/118183] Unable to rebuild the bootstrap tools and Wtypemi...
Gaius Mulley [Tue, 7 Jan 2025 11:20:45 +0000 (11:20 +0000)] 
[PR modula2/118010, modula2/118183] Unable to rebuild the bootstrap tools and Wtypemismatch

This patch combines fixes for both PR-118010 (Wtypemismatch) and PR-118183
(unable to rebuild the bootstrap tools).  PR-118010 required a new data
type (COFF_T) to be exported from SYSTEM and used in all return
types for libc.lseek.  The patch also includes COFF_T implemented in mc
and this data type has been propagated though the translated versions
of pge and mc.  Finally the patch adjusts the modula-2 declaration of
location_t to reflect the new gcc 64 bit type.

A new command line option -fm2-file-offset-bits= has been implemented to
override the default 64 bit declaration of COFF_T.

gcc/ChangeLog:

PR modula2/118010
* doc/gm2.texi (Compiler options): New option
-fm2-file-offset-bits=.

gcc/m2/ChangeLog:

PR modula2/118010
PR modula2/118183
* gm2-compiler/M2GCCDeclare.mod (Import): COffT, GetCOffTType.
(DeclareDefaultSimpleTypes): Declare COFF_T.
* gm2-compiler/M2GenGCC.mod (GetParamSize): Correct first
parameter to BuildSize to use location rather than a token position.
* gm2-compiler/M2Options.def (SetFileOffsetBits): New procedure.
(GetFileOffsetBits): New procedure function.
* gm2-compiler/M2Options.mod (SetFileOffsetBits): New procedure.
(GetFileOffsetBits): New procedure function.
(OffTBits): New variable.
* gm2-compiler/M2System.def (COffT): New variable.
* gm2-compiler/M2System.mod (MakeExtraSystemTypes): Declare
COffT.
* gm2-compiler/P1SymBuild.mod (EndBuildProcedure): Call
PutProcedureDefined.
* gm2-compiler/P2SymBuild.mod (Debug): Reimplement.
* gm2-compiler/SymbolTable.mod (InitProcedureDeclaration):
Initialize ProcedureTok.
* gm2-gcc/gcctypes.def (location_t): Declare as CARDINAL64.
* gm2-gcc/m2linemap.cc (m2linemap_GetLocationBinary): Add
call to linemap_add indication a LC_LEAVE.
* gm2-gcc/m2options.h (M2Options_SetFileOffsetBits): New procedure.
(M2Options_GetFileOffsetBits): New procedure function.
* gm2-gcc/m2type.cc (m2_offt_type_node): New variable.
(m2type_GetCSizeTType): Reword comment.
(m2type_GetCSSizeTType): Reword comment.
(m2type_GetCOffTType): New function.
(build_m2_offt_type_node): New function.
(m2type_InitSystemTypes): Initialize m2_offt_type_node.
* gm2-gcc/m2type.def (GetCSizeTType): Reword comment.
(GetCOffTType): New procedure function.
* gm2-gcc/m2type.h (m2type_GetCOffTType): New prototype.
* gm2-lang.cc (gm2_langhook_handle_option): New clause
OPT_fm2_file_offset_bits_.
* gm2-libs-coroutines/SYSTEM.def: Add COFF_T to export list.
* gm2-libs-iso/SYSTEM.def: Ditto.
* gm2-libs-min/SYSTEM.def: Ditto.
* gm2-libs/SYSTEM.def: Add COFF_T and CARDINAL64 to export list.
* gm2-libs/libc.def (lseek): Change return type to COFF_T.
* lang.opt (-fm2-file-offset-bits=): New option.
* mc-boot-ch/Glibc.c (libc_lseek): Change result to use off_t.
* mc-boot/GASCII.cc: Rebuilt.
* mc-boot/GASCII.h: Ditto.
* mc-boot/GArgs.cc: Ditto.
* mc-boot/GArgs.h: Ditto.
* mc-boot/GAssertion.cc: Ditto.
* mc-boot/GAssertion.h: Ditto.
* mc-boot/GBreak.cc: Ditto.
* mc-boot/GBreak.h: Ditto.
* mc-boot/GCOROUTINES.h: Ditto.
* mc-boot/GCmdArgs.cc: Ditto.
* mc-boot/GCmdArgs.h: Ditto.
* mc-boot/GDebug.cc: Ditto.
* mc-boot/GDebug.h: Ditto.
* mc-boot/GDynamicStrings.cc: Ditto.
* mc-boot/GDynamicStrings.h: Ditto.
* mc-boot/GEnvironment.cc: Ditto.
* mc-boot/GEnvironment.h: Ditto.
* mc-boot/GFIO.cc: Ditto.
* mc-boot/GFIO.h: Ditto.
* mc-boot/GFormatStrings.cc: Ditto.
* mc-boot/GFormatStrings.h: Ditto.
* mc-boot/GFpuIO.cc: Ditto.
* mc-boot/GFpuIO.h: Ditto.
* mc-boot/GIO.cc: Ditto.
* mc-boot/GIO.h: Ditto.
* mc-boot/GIndexing.cc: Ditto.
* mc-boot/GIndexing.h: Ditto.
* mc-boot/GM2Dependent.cc: Ditto.
* mc-boot/GM2Dependent.h: Ditto.
* mc-boot/GM2EXCEPTION.cc: Ditto.
* mc-boot/GM2EXCEPTION.h: Ditto.
* mc-boot/GM2RTS.cc: Ditto.
(M2RTS_Halt): Call libc_exit.
(M2RTS_HaltC): Ditto.
* mc-boot/GM2RTS.h: Rebuilt.
* mc-boot/GMemUtils.cc: Ditto.
* mc-boot/GMemUtils.h: Ditto.
* mc-boot/GNumberIO.cc: Ditto.
* mc-boot/GNumberIO.h: Ditto.
* mc-boot/GPushBackInput.cc: Ditto.
* mc-boot/GPushBackInput.h: Ditto.
* mc-boot/GRTExceptions.cc: Ditto.
* mc-boot/GRTExceptions.h: Ditto.
* mc-boot/GRTco.h: Ditto.
* mc-boot/GRTentity.h: Ditto.
* mc-boot/GRTint.cc: Ditto.
* mc-boot/GRTint.h: Ditto.
* mc-boot/GSArgs.cc: Ditto.
* mc-boot/GSArgs.h: Ditto.
* mc-boot/GSFIO.cc: Ditto.
* mc-boot/GSFIO.h: Ditto.
* mc-boot/GSYSTEM.h: Ditto.
* mc-boot/GSelective.h: Ditto.
* mc-boot/GStdIO.cc: Ditto.
* mc-boot/GStdIO.h: Ditto.
* mc-boot/GStorage.cc: Ditto.
* mc-boot/GStorage.h: Ditto.
* mc-boot/GStrCase.cc: Ditto.
* mc-boot/GStrCase.h: Ditto.
* mc-boot/GStrIO.cc: Ditto.
* mc-boot/GStrIO.h: Ditto.
* mc-boot/GStrLib.cc: Ditto.
* mc-boot/GStrLib.h: Ditto.
* mc-boot/GStringConvert.cc: Ditto.
* mc-boot/GStringConvert.h: Ditto.
* mc-boot/GSysExceptions.h: Ditto.
* mc-boot/GSysStorage.cc: Ditto.
* mc-boot/GSysStorage.h: Ditto.
* mc-boot/GTimeString.cc: Ditto.
* mc-boot/GTimeString.h: Ditto.
* mc-boot/GUnixArgs.h: Ditto.
* mc-boot/Galists.cc: Ditto.
* mc-boot/Galists.h: Ditto.
* mc-boot/Gdecl.cc: Ditto.
* mc-boot/Gdecl.h: Rebuilt.
* mc-boot/Gdtoa.h: Ditto.
* mc-boot/Gerrno.h: Ditto.
* mc-boot/Gkeyc.cc: Ditto.
* mc-boot/Gkeyc.h: Rebuilt.
* mc-boot/Gldtoa.h: Ditto.
* mc-boot/Glibc.h: Ditto.
* mc-boot/Glibm.h: Ditto.
* mc-boot/Glists.cc: Ditto.
* mc-boot/Glists.h: Ditto.
* mc-boot/GmcComment.cc: Ditto.
* mc-boot/GmcComment.h: Ditto.
* mc-boot/GmcComp.cc: Ditto.
* mc-boot/GmcComp.h: Ditto.
* mc-boot/GmcDebug.cc: Ditto.
* mc-boot/GmcDebug.h: Ditto.
* mc-boot/GmcError.cc: Ditto.
* mc-boot/GmcError.h: Ditto.
* mc-boot/GmcFileName.cc: Ditto.
* mc-boot/GmcFileName.h: Ditto.
* mc-boot/GmcLexBuf.cc: Ditto.
* mc-boot/GmcLexBuf.h: Ditto.
* mc-boot/GmcMetaError.cc: Ditto.
* mc-boot/GmcMetaError.h: Ditto.
* mc-boot/GmcOptions.cc: Ditto.
* mc-boot/GmcOptions.h: Ditto.
* mc-boot/GmcPreprocess.cc: Ditto.
* mc-boot/GmcPreprocess.h: Ditto.
* mc-boot/GmcPretty.cc: Ditto.
* mc-boot/GmcPretty.h: Ditto.
* mc-boot/GmcPrintf.cc: Ditto.
* mc-boot/GmcPrintf.h: Ditto.
* mc-boot/GmcQuiet.cc: Ditto.
* mc-boot/GmcQuiet.h: Ditto.
* mc-boot/GmcReserved.cc: Ditto.
* mc-boot/GmcReserved.h: Ditto.
* mc-boot/GmcSearch.cc: Ditto.
* mc-boot/GmcSearch.h: Ditto.
* mc-boot/GmcStack.cc: Ditto.
* mc-boot/GmcStack.h: Ditto.
* mc-boot/GmcStream.cc: Ditto.
* mc-boot/GmcStream.h: Ditto.
* mc-boot/Gmcflex.h: Ditto.
* mc-boot/Gmcp1.cc: Ditto.
* mc-boot/Gmcp1.h: Ditto.
* mc-boot/Gmcp2.cc: Ditto.
* mc-boot/Gmcp2.h: Ditto.
* mc-boot/Gmcp3.cc: Ditto.
* mc-boot/Gmcp3.h: Ditto.
* mc-boot/Gmcp4.cc: Ditto.
* mc-boot/Gmcp4.h: Ditto.
* mc-boot/Gmcp5.cc: Ditto.
* mc-boot/Gmcp5.h: Ditto.
* mc-boot/GnameKey.cc: Ditto.
* mc-boot/GnameKey.h: Ditto.
* mc-boot/GsymbolKey.cc: Ditto.
* mc-boot/GsymbolKey.h: Ditto.
* mc-boot/Gtermios.h: Ditto.
* mc-boot/Gtop.cc: Ditto.
* mc-boot/Gvarargs.cc: Ditto.
* mc-boot/Gvarargs.h: Ditto.
* mc-boot/Gwlists.cc: Ditto.
* mc-boot/Gwlists.h: Ditto.
* mc-boot/Gwrapc.h: Ditto.
* mc/decl.mod (cofft): New enum.
(cardinal64): Ditto.
(cofftN): New variable.
(cardinal64N): Ditto.
(isProcedure): Remove.
(getSymName): Add clause for cofft and cardinal64.
(makeBase): Ditto.
(isOrdinal): Ditto.
(getType): Ditto.
(doGetExprType): Ditto.
(getScope): Ditto.
(doExprC): Ditto.
(isSystem): Ditto.
(doSystemC): Ditto.
(doDependants): Ditto.
(visitDependants): Ditto.
(genKind): Ditto.
(doSystemM2): Ditto.
(doDupExpr): Ditto.
(makeSystem): Initialize cofftN and cardinal64N.
* mc/keyc.mod (useUIntMin): Remove.
(useUIntMax): Ditto.
* pge-boot/GIndexing.h: Rebuilt.
* pge-boot/GSEnvironment.h: Ditto.
* pge-boot/GScan.h: Ditto.
* pge-boot/Glibc.h: Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agoFortran: Extend cylic type detection for deallocate [PR116669]
Andre Vehreschild [Mon, 9 Dec 2024 13:56:27 +0000 (14:56 +0100)] 
Fortran: Extend cylic type detection for deallocate [PR116669]

Using cycles in derived/class types lead to the compiler doing a endless
recursion in several locations, when the cycle was not immediate.
An immediate cyclic dependency is present in, for example T T::comp.
Cylcic dependencies of the form T T2::comp; T2 T::comp2; are now
detected and the recursive bit in the derived type's attr is set.

gcc/fortran/ChangeLog:

PR fortran/116669

* class.cc (gfc_find_derived_vtab): Use attr to determine cyclic
type dependendies.
* expr.cc (gfc_has_default_initializer): Prevent endless
recursion by storing already visited derived types.
* resolve.cc (resolve_cyclic_derived_type): Determine if a type
is used in its hierarchy in a cyclic way.
(resolve_fl_derived0): Call resolve_cyclic_derived_type.
(resolve_fl_derived): Ensure vtab is generated when cyclic
derived types have allocatable components.
* trans-array.cc (structure_alloc_comps): Prevent endless loop
for derived type cycles.
* trans-expr.cc (gfc_get_ultimate_alloc_ptr_comps_caf_token):
Off topic, just prevent memory leaks.

gcc/testsuite/ChangeLog:

* gfortran.dg/class_array_15.f03: Freeing more memory.
* gfortran.dg/recursive_alloc_comp_6.f90: New test.

6 months agoAArch64: Remove AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS
Jennifer Schmitz [Tue, 26 Nov 2024 08:43:48 +0000 (00:43 -0800)] 
AArch64: Remove AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS

This patch removes the AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS tunable and
use_new_vector_costs entry in aarch64-tuning-flags.def and makes the
AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS paths in the backend the
default. To that end, the function aarch64_use_new_vector_costs_p and its uses
were removed. To prevent costing vec_to_scalar operations with 0, as
described in
https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665481.html,
we adjusted vectorizable_store such that the variable n_adjacent_stores
also covers vec_to_scalar operations. This way vec_to_scalar operations
are not costed individually, but as a group.
As suggested by Richard Sandiford, the "known_ne" in the multilane-check
was replaced by "maybe_ne" in order to treat nunits==1+1X as a vector
rather than a scalar.

Two tests were adjusted due to changes in codegen. In both cases, the
old code performed loop unrolling once, but the new code does not:
Example from gcc.target/aarch64/sve/strided_load_2.c (compiled with
-O2 -ftree-vectorize -march=armv8.2-a+sve -mtune=generic -moverride=tune=none):
f_int64_t_32:
        cbz     w3, .L92
        mov     x4, 0
        uxtw    x3, w3
+       cntd    x5
+       whilelo p7.d, xzr, x3
+       mov     z29.s, w5
        mov     z31.s, w2
-       whilelo p6.d, xzr, x3
-       mov     x2, x3
-       index   z30.s, #0, #1
-       uqdecd  x2
-       ptrue   p5.b, all
-       whilelo p7.d, xzr, x2
+       index   z30.d, #0, #1
+       ptrue   p6.b, all
        .p2align 3,,7
 .L94:
-       ld1d    z27.d, p7/z, [x0, #1, mul vl]
-       ld1d    z28.d, p6/z, [x0]
-       movprfx z29, z31
-       mul     z29.s, p5/m, z29.s, z30.s
-       incw    x4
-       uunpklo z0.d, z29.s
-       uunpkhi z29.d, z29.s
-       ld1d    z25.d, p6/z, [x1, z0.d, lsl 3]
-       ld1d    z26.d, p7/z, [x1, z29.d, lsl 3]
-       add     z25.d, z28.d, z25.d
+       ld1d    z27.d, p7/z, [x0, x4, lsl 3]
+       movprfx z28, z31
+       mul     z28.s, p6/m, z28.s, z30.s
+       ld1d    z26.d, p7/z, [x1, z28.d, uxtw 3]
        add     z26.d, z27.d, z26.d
-       st1d    z26.d, p7, [x0, #1, mul vl]
-       whilelo p7.d, x4, x2
-       st1d    z25.d, p6, [x0]
-       incw    z30.s
-       incb    x0, all, mul #2
-       whilelo p6.d, x4, x3
+       st1d    z26.d, p7, [x0, x4, lsl 3]
+       add     z30.s, z30.s, z29.s
+       incd    x4
+       whilelo p7.d, x4, x3
        b.any   .L94
 .L92:
        ret

Example from gcc.target/aarch64/sve/strided_store_2.c (compiled with
-O2 -ftree-vectorize -march=armv8.2-a+sve -mtune=generic -moverride=tune=none):
f_int64_t_32:
        cbz     w3, .L84
-       addvl   x5, x1, #1
        mov     x4, 0
        uxtw    x3, w3
-       mov     z31.s, w2
+       cntd    x5
        whilelo p7.d, xzr, x3
-       mov     x2, x3
-       index   z30.s, #0, #1
-       uqdecd  x2
-       ptrue   p5.b, all
-       whilelo p6.d, xzr, x2
+       mov     z29.s, w5
+       mov     z31.s, w2
+       index   z30.d, #0, #1
+       ptrue   p6.b, all
        .p2align 3,,7
 .L86:
-       ld1d    z28.d, p7/z, [x1, x4, lsl 3]
-       ld1d    z27.d, p6/z, [x5, x4, lsl 3]
-       movprfx z29, z30
-       mul     z29.s, p5/m, z29.s, z31.s
-       add     z28.d, z28.d, #1
-       uunpklo z26.d, z29.s
-       st1d    z28.d, p7, [x0, z26.d, lsl 3]
-       incw    x4
-       uunpkhi z29.d, z29.s
+       ld1d    z27.d, p7/z, [x1, x4, lsl 3]
+       movprfx z28, z30
+       mul     z28.s, p6/m, z28.s, z31.s
        add     z27.d, z27.d, #1
-       whilelo p6.d, x4, x2
-       st1d    z27.d, p7, [x0, z29.d, lsl 3]
-       incw    z30.s
+       st1d    z27.d, p7, [x0, z28.d, uxtw 3]
+       incd    x4
+       add     z30.s, z30.s, z29.s
        whilelo p7.d, x4, x3
        b.any   .L86
 .L84:
ret

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

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
* tree-vect-stmts.cc (vectorizable_store): Extend the use of
n_adjacent_stores to also cover vec_to_scalar operations.
* config/aarch64/aarch64-tuning-flags.def: Remove
use_new_vector_costs as tuning option.
* config/aarch64/aarch64.cc (aarch64_use_new_vector_costs_p):
Remove.
(aarch64_vector_costs::add_stmt_cost): Remove use of
aarch64_use_new_vector_costs_p.
(aarch64_vector_costs::finish_cost): Remove use of
aarch64_use_new_vector_costs_p.
* config/aarch64/tuning_models/cortexx925.h: Remove
AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS.
* config/aarch64/tuning_models/fujitsu_monaka.h: Likewise.
* config/aarch64/tuning_models/generic_armv8_a.h: Likewise.
* config/aarch64/tuning_models/generic_armv9_a.h: Likewise.
* config/aarch64/tuning_models/neoverse512tvb.h: Likewise.
* config/aarch64/tuning_models/neoversen2.h: Likewise.
* config/aarch64/tuning_models/neoversen3.h: Likewise.
* config/aarch64/tuning_models/neoversev1.h: Likewise.
* config/aarch64/tuning_models/neoversev2.h: Likewise.
* config/aarch64/tuning_models/neoversev3.h: Likewise.
* config/aarch64/tuning_models/neoversev3ae.h: Likewise.

gcc/testsuite/
* gcc.target/aarch64/sve/strided_load_2.c: Adjust expected outcome.
* gcc.target/aarch64/sve/strided_store_2.c: Likewise.

6 months agotestsuite: add testcase for fixed PR98000
Sam James [Fri, 3 Jan 2025 16:59:37 +0000 (16:59 +0000)] 
testsuite: add testcase for fixed PR98000

gcc/testsuite/ChangeLog:
PR ipa/98000
* g++.dg/ipa/pr98000.C: New test.

6 months agotestsuite: add testcase for fixed PR117546
Sam James [Fri, 3 Jan 2025 16:56:01 +0000 (16:56 +0000)] 
testsuite: add testcase for fixed PR117546

PR117546 was fixed by Eric's r14-10693-gadab597af288d6 change, but
the testcase here is sufficiently different to be worth including
in torture/.

gcc/testsuite/ChangeLog:
PR ipa/117546
* gcc.dg/torture/pr117546.c: New test.

6 months agoDaily bump.
GCC Administrator [Tue, 7 Jan 2025 00:18:08 +0000 (00:18 +0000)] 
Daily bump.

6 months agoexpand: drop stack adjustments after barrier [PR118006]
Alexandre Oliva [Fri, 20 Dec 2024 21:02:08 +0000 (18:02 -0300)] 
expand: drop stack adjustments after barrier [PR118006]

A gimple block with __builtin_unreachable () can't have code after it,
and gimple optimizers ensure there isn't any, even without
optimization.  But if the block requires stack adjustments,
e.g. because of a call that passes arguments on the stack, expand will
emit that after the barrier, and then rtl checkers rightfully
complain.  Arrange to discard adjustments after a barrier.

Strub expanders seem to be necessary to bring about the exact
conditions that require stack adjustments after the block that ends
with a __builtin_unreachable call.

for  gcc/ChangeLog

PR middle-end/118006
* cfgexpand.cc (expand_gimple_basic_block): Do not emit
pending stack adjustments after a barrier.

for  gcc/testsuite/ChangeLog

PR middle-end/118006
* gcc.target/i386/strub-pr118006.c: New.

6 months agoaarch64: remove extra XTN in vector concatenation
Akram Ahmad [Mon, 6 Jan 2025 20:09:30 +0000 (20:09 +0000)] 
aarch64: remove extra XTN in vector concatenation

GIMPLE code which performs a narrowing truncation on the result of a
vector concatenation currently results in an unnecessary XTN being
emitted following a UZP1 to concate the operands. In cases such as this,
UZP1 should instead use a smaller arrangement specifier to replace the
XTN instruction. This is seen in cases such as in this GIMPLE example:

int32x2_t foo (svint64_t a, svint64_t b)
{
  vector(2) int vect__2.8;
  long int _1;
  long int _3;
  vector(2) long int _12;

  <bb 2> [local count: 1073741824]:
  _1 = svaddv_s64 ({ -1, 0, 0, 0, 0, 0, 0, 0, ... }, a_6(D));
  _3 = svaddv_s64 ({ -1, 0, 0, 0, 0, 0, 0, 0, ... }, b_7(D));
  _12 = {_1, _3};
  vect__2.8_13 = (vector(2) int) _12;
  return vect__2.8_13;

}

Original assembly generated:

bar:
        ptrue   p3.b, all
        uaddv   d0, p3, z0.d
        uaddv   d1, p3, z1.d
        uzp1    v0.2d, v0.2d, v1.2d
        xtn     v0.2s, v0.2d
        ret

This patch therefore defines the *aarch64_trunc_concat<mode> insn which
truncates the concatenation result, rather than concatenating the
truncated operands (such as in *aarch64_narrow_trunc<mode>), resulting
in the following optimised assembly being emitted:

bar:
        ptrue   p3.b, all
        uaddv   d0, p3, z0.d
        uaddv   d1, p3, z1.d
        uzp1    v0.2s, v0.2s, v1.2s
        ret

This patch passes all regression tests on aarch64 with no new failures.
A supporting test for this optimisation is also written and passes.

OK for master? I do not have commit rights so I cannot push the patch
myself.

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md: (*aarch64_trunc_concat)
new insn definition.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/truncated_concatenation_1.c: new test
for the above example and other modes covered by insn
definitions.

6 months agoFix type in some Min() calls (#119248)
Stefan Schulze Frielinghaus [Mon, 6 Jan 2025 18:17:28 +0000 (19:17 +0100)] 
Fix type in some Min() calls (#119248)

This is a follow-up to 6dec33834d1fd89f16e271dde9607c1de9554144 and
pull requests #116957 and #119114.

Cherry picked from LLVM commit 65a2eb0b1589590ae78cc1e5f05cd004b3b3bec5.

libsanitizer/ChangeLog:

PR sanitizer/117725
* sanitizer_common/sanitizer_common_interceptors.inc: Cherry
picked from LLVM commit 65a2eb0b1589590ae78cc1e5f05cd004b3b3bec5.

6 months agoFix few size types in memprof (#119114)
Vitaly Buka [Mon, 6 Jan 2025 18:17:09 +0000 (19:17 +0100)] 
Fix few size types in memprof (#119114)

Fix type in a few related Min() calls.

Follow up to #116957.

Cherry picked from LLVM commit 6dec33834d1fd89f16e271dde9607c1de9554144
(removed memprof part).

libsanitizer/ChangeLog:

PR sanitizer/117725
* asan/asan_interceptors.cpp: Cherry picked from LLVM commit
6dec33834d1fd89f16e271dde9607c1de9554144.
* sanitizer_common/sanitizer_common_interceptors.inc: Ditto.

Co-authored-by: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
6 months agoAdd type __sanitizer::ssize (#116957)
Stefan Schulze Frielinghaus [Mon, 6 Jan 2025 18:17:09 +0000 (19:17 +0100)] 
Add type __sanitizer::ssize (#116957)

Since the sanitizer merge in commit r15-5164-gfa321004f3f628 of GCC
which entails LLVM commit 61a6439f35b6de28ff4aff4450d6fca970292fd5, GCCs
bootstrap is broken on s390 -m31. This is due to commit
ec68dc1ca4d967b599f1202855917d5ec9cae52f which introduces stricter type
checking which is why GCC bootstrap fails with

```
In file included from /gcc/src/libsanitizer/interception/interception.h:18,
                 from /gcc/src/libsanitizer/interception/interception_type_test.cpp:14:
/gcc/src/libsanitizer/interception/interception_type_test.cpp:30:61: error: static assertion failed
   30 | COMPILER_CHECK((__sanitizer::is_same<::SSIZE_T, ::ssize_t>::value));
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/gcc/src/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:363:44: note: in definition of macro 'COMPILER_CHECK'
  363 | #define COMPILER_CHECK(pred) static_assert(pred, "")
      |                                            ^~~~
make[8]: *** [Makefile:469: interception_type_test.lo] Error 1
```

The culprit seems to be that we don't check for equality of type sizes
anymore but rather whether the types are indeed the same. On s390 -m31
we have that `sizeof(int)==sizeof(long)` holds which is why previously
the checks succeeded. They fail now because

```
size_t      => unsigned long
ssize_t     => long
ptrdiff_t   => int
::SSIZE_T   => __sanitizer::sptr => int
::PTRDIFF_T => __sanitizer::sptr => int
```

This is fixed by mapping `SSIZE_T` to `long` in the end.

```
typedef long ssize;
typedef sptr ssize;

```

Cherry picked from LLVM commit ce44640fe29550461120d22b0358e6cac4aed822.

libsanitizer/ChangeLog:

PR sanitizer/117725
* interception/interception.h: Cherry picked from LLVM commit
ce44640fe29550461120d22b0358e6cac4aed822.
* sanitizer_common/sanitizer_internal_defs.h: Ditto.

6 months agoReplace uptr by usize/SIZE_T in interfaces
Stefan Schulze Frielinghaus [Mon, 6 Jan 2025 18:17:09 +0000 (19:17 +0100)] 
Replace uptr by usize/SIZE_T in interfaces

For some targets uptr is mapped to unsigned int and size_t to unsigned
long and sizeof(int)==sizeof(long) holds.  Still, these are distinct
types and type checking may fail.  Therefore, replace uptr by
usize/SIZE_T wherever a size_t is expected.

Part of #116957

Cherry picked from LLVM commit 9a156f6b2b0c892d8713ba907f07f027b24953d8
(removed memprof, msan, and nsan parts).

libsanitizer/ChangeLog:

PR sanitizer/117725
* asan/asan_interceptors.cpp: Cherry picked LLVM commit
9a156f6b2b0c892d8713ba907f07f027b24953d8.
* asan/asan_interceptors.h: Ditto.
* asan/asan_interceptors_memintrinsics.h: Ditto.
* sanitizer_common/sanitizer_common_interceptors.inc: Ditto.
* sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:
Ditto.
* sanitizer_common/sanitizer_platform_limits_posix.h: Ditto.
* tsan/tsan_interceptors_posix.cpp: Ditto.

6 months agocrypto/tls: fix Config.Time in tests using expired certificates
Ian Lance Taylor [Sat, 4 Jan 2025 23:54:58 +0000 (15:54 -0800)] 
crypto/tls: fix Config.Time in tests using expired certificates

This is a backport of https://go.dev/cl/640237 from the main repo.

Fixes PR go/118286

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/640435

6 months agoor1k: add .note.GNU-stack section on linux
Stafford Horne [Mon, 6 Jan 2025 12:12:40 +0000 (12:12 +0000)] 
or1k: add .note.GNU-stack section on linux

In the OpenRISC build we get the following warning:

    ld: warning: __modsi3_s.o: missing .note.GNU-stack section implies executable stack
    ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

Fix this by adding a .note.GNU-stack to indicate the stack does not need to be
executable for the lib1funcs.

Note, this is also needed for the upcoming glibc 2.41.

libgcc/
* config/or1k/lib1funcs.S: Add .note.GNU-stack section on linux.

6 months agoRespect -fprofile-prefix-map for getcwd in .gcno files
Fangrui Song [Wed, 1 Jan 2025 00:32:07 +0000 (16:32 -0800)] 
Respect -fprofile-prefix-map for getcwd in .gcno files

so that
`gcc -c a.cc --coverage -fprofile-prefix-map=$PWD=.`
does not emit $PWD in the generated a.gcno file.

gcc/ChangeLog:

PR gcov-profile/96092
* coverage.cc (coverage_init): Remap getpwd().

6 months agoSVE intrinsics: Fold svmul by -1 to svneg for unsigned types
Jennifer Schmitz [Thu, 7 Nov 2024 16:44:30 +0000 (08:44 -0800)] 
SVE intrinsics: Fold svmul by -1 to svneg for unsigned types

As follow-up to
https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665472.html,
this patch implements folding of svmul by -1 to svneg for
unsigned SVE vector types. The key idea is to reuse the existing code that
does this fold for signed types and feed it as callback to a helper function
that adds the necessary type conversions.

For example, for the test case
svuint64_t foo (svuint64_t x, svbool_t pg)
{
  return svmul_n_u64_x (pg, x, -1);
}

the following gimple sequence is emitted (-O2 -mcpu=grace):
svuint64_t foo (svuint64_t x, svbool_t pg)
{
  svint64_t D.12921;
  svint64_t D.12920;
  svuint64_t D.12919;

  D.12920 = VIEW_CONVERT_EXPR<svint64_t>(x);
  D.12921 = svneg_s64_x (pg, D.12920);
  D.12919 = VIEW_CONVERT_EXPR<svuint64_t>(D.12921);
  goto <D.12922>;
  <D.12922>:
  return D.12919;
}

In general, the new helper gimple_folder::convert_and_fold
- takes a target type and a function pointer,
- converts the lhs and all non-boolean vector types to the target type,
- passes the converted lhs and arguments to the callback,
- receives the new gimple statement from the callback function,
- adds the necessary view converts to the gimple sequence,
- and returns the new call.

Because all arguments are converted to the same target types, the helper
function is only suitable for folding calls whose arguments are all of
the same type. If necessary, this could be extended to convert the
arguments to different types differentially.

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

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-base.cc
(svmul_impl::fold): Wrap code for folding to svneg in lambda
function and pass to gimple_folder::convert_and_fold to enable
the transform for unsigned types.
* config/aarch64/aarch64-sve-builtins.cc
(gimple_folder::convert_and_fold): New function that converts
operands to target type before calling callback function, adding the
necessary conversion statements.
(gimple_folder::redirect_call): Set fntype of redirected call.
(get_vector_type): Move from here to aarch64-sve-builtins.h.
* config/aarch64/aarch64-sve-builtins.h
(gimple_folder::convert_and_fold): Declare function.
(get_vector_type): Move here as inline function.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/acle/asm/mul_u8.c: Adjust expected outcome.
* gcc.target/aarch64/sve/acle/asm/mul_u16.c: Likewise.
* gcc.target/aarch64/sve/acle/asm/mul_u32.c: Likewise.
* gcc.target/aarch64/sve/acle/asm/mul_u64.c: New test and adjust
expected outcome.

6 months agoAda: fix spurious relinking of gnatbind for cross compilers
Eric Botcazou [Mon, 6 Jan 2025 11:20:00 +0000 (12:20 +0100)] 
Ada: fix spurious relinking of gnatbind for cross compilers

The problem has been introduced by r15-1881.

gcc/ada
PR ada/118247
* gcc-interface/Make-lang.in (GNATTOOLS_CROSS_MV): Copy gnatbind
instead of moving it.

6 months agoipa-cp: Make dumping of bit masks representing -1 nicer
Martin Jambor [Mon, 6 Jan 2025 10:58:29 +0000 (11:58 +0100)] 
ipa-cp: Make dumping of bit masks representing -1 nicer

Dumps of the lattices representing bit-values and of propagation
results of bit-values can print a really long hexadecimal value when
the bit-value represents -1 (all bits set).  This patch simply detect
that situation and prints the string "-1" in that case, making the
dumps somewhat nicer.

gcc/ChangeLog:

2025-01-03  Martin Jambor  <mjambor@suse.cz>

* ipa-cp.cc (ipcp_print_widest_int): New function.
(ipcp_store_vr_results): Use it.
(ipcp_bits_lattice::print): Likewise.  Fix formatting.

6 months agotree-switch-conversion: don't apply switch size limit on jump tables
Mark Wielaard [Sun, 5 Jan 2025 17:00:36 +0000 (18:00 +0100)] 
tree-switch-conversion: don't apply switch size limit on jump tables

commit 56946c801a7c ("gimple: Add limit after which slower switchlower
algs are used [PR117091] [PR117352]") introduced a limit on the number
of cases of a switch. It also bails out on finding jump tables if the
switch is too large. This introduces a compile time regression during
bootstrap. A riscv bootstrap takes hours longer. Particularly
insn-attrtab.cc will take hours instead of minutes. Fix this by not
applying the switch size limit on jump tables.

An alternative would be to implement greedy switch clustering for jump
tables as is done for switch bitmap clustering.

gcc/ChangeLog:

PR tree-optimization/118032
* tree-switch-conversion.cc (jump_table_cluster::find_jump_tables):
Remove param_switch_lower_slow_alg_max_cases check.

6 months agoAArch64: Implement four and eight chunk VLA concats [PR118272]
Tamar Christina [Mon, 6 Jan 2025 09:24:36 +0000 (09:24 +0000)] 
AArch64: Implement four and eight chunk VLA concats [PR118272]

The following testcase

  #pragma GCC target ("+sve")
  extern char __attribute__ ((simd, const)) fn3 (int, short);
  void test_fn3 (float *a, float *b, double *c, int n)
  {
    for (int i = 0; i < n; ++i)
      a[i] = fn3 (b[i], c[i]);
  }

at -Ofast ICEs because my previous patch only added support for combining 2
partial SVE vectors into a bigger vector.  However There can also 4 and 8
piece subvectors.

This patch fixes this by implementing the missing expansions.

gcc/ChangeLog:

PR target/96342
PR target/118272
* config/aarch64/aarch64-sve.md (vec_init<mode><Vquad>,
vec_initvnx16qivnx2qi): New.
* config/aarch64/aarch64.cc (aarch64_sve_expand_vector_init_subvector):
Rewrite to support any arbitrary combinations.
* config/aarch64/iterators.md (SVE_NO2E): Update to use SVE_NO4E
(SVE_NO2E, Vquad): New.

gcc/testsuite/ChangeLog:

PR target/96342
PR target/118272
* gcc.target/aarch64/vect-simd-clone-3.c: New test.

6 months agoada: Fix small thinko in previous change to two-pass aggregate expansion
Eric Botcazou [Fri, 13 Dec 2024 19:50:44 +0000 (20:50 +0100)] 
ada: Fix small thinko in previous change to two-pass aggregate expansion

We need a type tailored to the base index type to compute the length.

gcc/ada/ChangeLog:

* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Use the base type of
the index type to find the type used to compute the length.

6 months agoada: Streamline runtime support of finalization collections
Eric Botcazou [Fri, 13 Dec 2024 18:17:00 +0000 (19:17 +0100)] 
ada: Streamline runtime support of finalization collections

Finalization collections are declared as (limited) controlled types so that
they can be naturally attached to a finalization master, but the same result
can be achieved by means of (limited) finalizable types, which need not be
tagged and thus avoid dragging the runtime support of tagged types.

gcc/ada/ChangeLog:

* libgnat/s-finpri.ads: Remove clause for Ada.Finalization.
(Finalization_Collection): Change to limited private type with the
Finalizable aspect.
(Initialize): Remove "overriding" keyword.
(Finalize): Likewise.
* libgnat/s-finpri.adb (Initialize): Likewise.
(Finalize): Likewise.

6 months agoada: Fix predicate involving array indexing rejected in generic package
Eric Botcazou [Thu, 12 Dec 2024 22:08:30 +0000 (23:08 +0100)] 
ada: Fix predicate involving array indexing rejected in generic package

The indexing is rejected with the message:

  error: reference to current instance of type does not denote a type

when it is applied to a prefix which is the current instance of the type
to which the predicate is applied.

There is already a specific handling of component selection for this case
present in Find_Selected_Component, so this adds an equivalent specific
handling of indexing for this case to Analyze_Indexed_Component_Form.

gcc/ada/ChangeLog:

PR ada/117569
* sem_ch4.adb (Analyze_Indexed_Component_Form): Do not rewrite the
node as a type conversion if it is the current instance of a type
in a generic unit.
* sem_ch8.adb (Find_Selected_Component): Restrict the special case
of the current instance of a type to a generic unit.

6 months agoada: Fix incorrect RM reference in s-imagef.adb
Bob Duff [Fri, 13 Dec 2024 13:58:08 +0000 (08:58 -0500)] 
ada: Fix incorrect RM reference in s-imagef.adb

gcc/ada/ChangeLog:

* libgnat/s-imagef.adb (Set_Image_Integer):
Change "RM A.3.10" to be "RM A.10.9".

6 months agoada: Reduce footprint of C++ exception interoperation support
Alexandre Oliva [Tue, 10 Dec 2024 12:06:57 +0000 (09:06 -0300)] 
ada: Reduce footprint of C++ exception interoperation support

The initial C++ base-type exception interoperation support change
brought all of GNAT.CPP* along with raise-gcc, because of
[__gnat_]Convert_Caught_Object.  Move that private but pragma-exported
function to GNAT.CPP.Std.Type_Info, so that it can rely on the C++
virtual/dispatch calls that justified the introduction of the Ada
wrapper type, to avoid emulating virtual calls in C or bringing in a
dependency on the C++ compiler and runtime.

Drop the CharPtr package instantiation, that brought a huge amount of
unnecessary code, and use string and storage primitives instead, using
the strcmp builtin directly for the C string compares.

Move the conversion to Ada String in Name to the wrapper interface in
GNAT.CPP.Std, adjusting the private internal type to shave off a few
more bytes from the only unit that raise-gcc will still need.

Finally, disable heap finalization for Type_Info_Ptr, to avoid
dragging in all of the finalization code.  Thank to Eric Botcazou for
the suggestion.

gcc/ada/ChangeLog:

* libgnat/g-cppexc.adb (Convert_Caught_Object): Move...
* libgnat/g-cstyin.adb (Convert_Caught_Object):  ... here.
Use object call notation.
(strcmp): New.
(Char_Arr, CharPtr, Char_Pointer, To_chars_ptr): Drop.  Do not
import Interfaces.C.Pointers.
(To_Pointer): Convert from System.Address.
(Name_Starts_With_Asterisk): Rename local variable.
(Name_Past_Asterisk): Rewrite with System.Address and strcmp.
Import System.Storage_Elements.
(Equals): Use strcmp.
(Before): Fix logic error.  Use strcmp.
(Name): Move conversion to String...
* libgnat/g-cppstd.adb (Name): ... here.  Import
Interfaces.C.Strings.
* libgnat/g-cppstd.ads (Type_Info_Ptr): Disable heap
finalization.
* libgnat/g-cstyin.ads (Name): Change return type.

6 months agoada: Support new SPARK aspect Exit_Cases
Claire Dross [Mon, 2 Dec 2024 16:14:47 +0000 (17:14 +0100)] 
ada: Support new SPARK aspect Exit_Cases

The aspect Exit_Cases allows annotating a subprogram with a list of
cases specifying, for all input which satisfy a guard, how the
subprogram is allowed to terminate. For now, it can only be either
returning normally or propagating an exception. This contract is not
checked at runtime, it is only meant for static verification in SPARK.

gcc/ada/ChangeLog:

* aspects.ads: Add aspect Aspect_Exit_Cases.
* contracts.adb (Analyze_Entry_Or_Subprogram_Contract): Handle Exit_Cases.
(Expand_Subprogram_Contract): Idem.
* einfo-utils.adb (Get_Pragma): Allow Pragma_Exit_Cases.
* einfo-utils.ads (Get_Pragma): Idem.
* exp_prag.adb (Expand_Pragma_Exit_Cases): Ignore the pragma, currently we don't expand it.
* exp_prag.ads (Expand_Pragma_Exit_Cases): Idem.
* inline.adb (Remove_Aspects_And_Pragmas): Add Exit_Cases to the list.
(Remove_Items): Idem.
* par-prag.adb (Last_Arg_Is_Reason): Idem.
* sem_ch12.adb: Idem.
* sem_ch13.adb: Idem.
* sem_util.adb: Idem.
* sem_util.ads: Idem.
* sinfo.ads: Idem.
* snames.ads-tmpl: Add names Name_Exit_Cases, Name_Exception_Raised, and Name_Normal_Return
as well as pragma Pragma_Exit_Cases.
* sem_prag.adb (Analyze_Exit_Cases_In_Decl_Part): Make sure that a
pragma or aspect Exit_Cases is well formed.
(Analyze_Pragma): Make sure that a pragma or aspect Exit_Cases is at the right place.
* sem_prag.ads (Analyze_Exit_Cases_In_Decl_Part): Declaration.
* doc/gnat_rm/implementation_defined_pragmas.rst: Document the Exit_Cases pragma.
* doc/gnat_rm/implementation_defined_aspects.rst: Document the Exit_Cases aspect.
* gnat_rm.texi: Regenerate.

6 months agoada: Correct xref of operator expression function body
Bob Duff [Thu, 12 Dec 2024 14:13:16 +0000 (09:13 -0500)] 
ada: Correct xref of operator expression function body

For an expression function body that is an operator,
make sure the xref entry in the ALI file points one past the
double quote mark. For example, if the name is ">", point
to the greater-than symbol, not the double quote.
This was already the case for proper bodies.

gcc/ada/ChangeLog:

* sem_util.adb (Copy_Subprogram_Spec): When copying
an N_Defining_Operator_Symbol, create an
N_Defining_Operator_Symbol rather than an N_Defining_Identifier.
This will cause Lib.Xref to "skip the initial quote for
navigation purposes" (as per comments in Lib.Xref body).

6 months agoada: Small housekeeping work in Exp_Aggr
Eric Botcazou [Thu, 12 Dec 2024 12:00:14 +0000 (13:00 +0100)] 
ada: Small housekeeping work in Exp_Aggr

This moves a few declarations around and tweaks a few comments.

gcc/ada/ChangeLog:

* exp_aggr.adb (Case_Table_Type): Fix reference in comment.
(In_Place_Assign_OK): Move declaration around.
(Is_Build_In_Place_Aggregate_Return): Likewise and adjust.
(Expand_Array_Aggregate): Streamline for the sake of consistency.
(Aggr_Assignment_OK_For_Backend): Remove reference to Gigi/gcc.
(Backend_Processing_Possible): Likewise.
(Expand_Array_Aggregate): Add comment.

6 months agoada: cleanup documentation for shift and rotate
Bob Duff [Tue, 10 Dec 2024 13:56:45 +0000 (08:56 -0500)] 
ada: cleanup documentation for shift and rotate

Documentation updated.

gcc/ada/ChangeLog:

* sinfo.ads (Shift_Count_OK): Update comments.
(Is_Power_Of_2_For_Shift): Likewise.

6 months agoada: Fix memory leak when failing to initialize newly allocated memory
Eric Botcazou [Tue, 10 Dec 2024 18:43:14 +0000 (19:43 +0100)] 
ada: Fix memory leak when failing to initialize newly allocated memory

This makes the compiler generate cleanup code to deallocate the memory when
the evaluation of the expression of an allocator raises an exception, if the
expression is a call to a function that may raise, i.e. is not declared with
the No_Raise aspect/pragma.  This can also be disabled by means of -gnatdQ.

gcc/ada/ChangeLog:

* debug.adb (dQ): Document usage.
* exp_ch4.ads (Build_Cleanup_For_Allocator): New declaration.
* exp_ch4.adb (Build_Cleanup_For_Allocator): New procedure.
(Expand_Allocator_Expression): Build a cleanup to deallocate the
memory when the evaluation of the expression raises an exception.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.
* exp_util.adb (Build_Allocate_Deallocate_Proc): Do not generate the
detachment if the deallocation is for the cleanup of an allocator.
* gen_il-fields.ads (Opt_Field_Enum): Add For_Allocator.
* gen_il-gen-gen_nodes.adb (N_Free_Statement): Likewise.
* sinfo.ads (For_Allocator): Document usage on N_Free_Statement.

6 months agoada: Fix assertion failure on 'Old in post-condition with -gnat2022
Eric Botcazou [Wed, 11 Dec 2024 12:06:07 +0000 (13:06 +0100)] 
ada: Fix assertion failure on 'Old in post-condition with -gnat2022

It comes from a small oversight in the updated implementation for Ada 2022.

gcc/ada/ChangeLog:

PR ada/117956
* sem_util.adb (Is_Known_On_Entry): Be prepared for constants coming
from a renaming declaration.

6 months agoada: Declare that the new argument may not be used
Tonu Naks [Tue, 10 Dec 2024 10:41:16 +0000 (10:41 +0000)] 
ada: Declare that the new argument may not be used

gcc/ada/ChangeLog:

* adaint.c (__gnat_locate_exec_on_path): modify function signature

6 months agoada: Fix crash on Depends contract with homonym functions
Piotr Trojanek [Tue, 10 Dec 2024 15:42:46 +0000 (16:42 +0100)] 
ada: Fix crash on Depends contract with homonym functions

When resolving names in flow contracts, we refine the ordinary analysis by
knowing that an overloaded name must refer to an abstract state and not a
function. However, when all overloadings refer to function, we shouldn't
crash, but instead let the error to be diagnosed later.

gcc/ada/ChangeLog:

* sem_prag.adb (Resolve_State): Continue ordinary processing.

6 months agoada: Crash in prefix notation with access to class-wide object
Javier Miranda [Tue, 10 Dec 2024 19:49:15 +0000 (19:49 +0000)] 
ada: Crash in prefix notation with access to class-wide object

The compiler crashes analyzing a prefix notation call when its
prefix is an access to a class-wide object, an actual parameter
is missing, and the sources are compiled with language extensions
(-gnatX) and full errors (-gnatf).

gcc/ada/ChangeLog:

* sem_ch4.adb (Try_Object_Operation): if no candidate interpretation
matches the context, redo the same analysis with Report_Error True
to report the error.

6 months agoada: Plug small loophole in previous change
Eric Botcazou [Tue, 10 Dec 2024 16:53:34 +0000 (17:53 +0100)] 
ada: Plug small loophole in previous change

The initial change only deals with the controlled record case for assignment
statements, but the controlled array case needs the same treatment.

gcc/ada/ChangeLog:

* exp_ch5.adb (Expand_Assign_Array): Bail out for controlled
components if the RHS is a function call and the assignment has
the No_Ctrl_Actions flag set.

6 months agoada: Fix printing boolean attributes in the SARIF report
Viljar Indus [Tue, 26 Nov 2024 12:10:46 +0000 (14:10 +0200)] 
ada: Fix printing boolean attributes in the SARIF report

Boolean attributes should have the value true or false
without any quotes.

gcc/ada/ChangeLog:

* diagnostics-json_utils.adb: Add new method
Write_Boolean_Attribute.
* diagnostics-json_utils.ads: Likewise.
* diagnostics-sarif_emitter.adb (Print_Invocations): print
the executionSuccesful property value without extra quotes.

6 months agoada: Remove level attribute from Rules in the SARIF report
Viljar Indus [Thu, 28 Nov 2024 10:44:37 +0000 (12:44 +0200)] 
ada: Remove level attribute from Rules in the SARIF report

A Rule object in the SARIF report does not have a level
attribute. Result objects are the elements in the SARIF
reprot that have a level attribute that ultimately determines
the level of each diagnostic object.

Rules can have a defaultConfiguration attribute which has a level
attribute that can be overridden in multiple ways. This can make
the overall report more complex than it needs to be. It is simpler
to remove the attribute from rules where it does not really matter
and add it back in under the defaultConfiguration when there is an
explicit need for it.

gcc/ada/ChangeLog:

* diagnostics-sarif_emitter.adb (Print_Rule): Remove printing
of the level attribute since it does not match the SARIF schema.

6 months agoada: Avoid null-exclusion checks for Node_Field_Table
Piotr Trojanek [Wed, 27 Sep 2023 10:19:53 +0000 (12:19 +0200)] 
ada: Avoid null-exclusion checks for Node_Field_Table

By generating the type of Node_Field_Table with a "not null" qualifier
we check the null exclusion of its elements only once, at the object
declaration.

Tiny performance improvement for the debug builds (because in production
builds checks are disabled anyway); semantics is unaffected.

gcc/ada/ChangeLog:

* gen_il-gen.adb (Put_Tables): Add "not null" to the generated code.
* rtsfind.adb (Cstring_Ptr): Same for table with predefined RE_Id
error messages.
* impunit.adb (Aunit_Record): Same for array of alternative unit names.