]> gcc.gnu.org Git - gcc.git/log
gcc.git
13 months agoi386: Add peephole2 patterns to improve add with carry or subtract with borrow with...
Jakub Jelinek [Thu, 15 Jun 2023 07:05:01 +0000 (09:05 +0200)]
i386: Add peephole2 patterns to improve add with carry or subtract with borrow with memory destination [PR79173]

This patch adds various peephole2s which help to recognize add with
carry or subtract with borrow with memory destination.

2023-06-14  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/79173
* config/i386/i386.md (*sub<mode>_3, @add<mode>3_carry,
addcarry<mode>, @sub<mode>3_carry, *add<mode>3_cc_overflow_1): Add
define_peephole2 TARGET_READ_MODIFY_WRITE/-Os patterns to prefer
using memory destination in these patterns.

13 months agomiddle-end: Move constant args folding of .UBSAN_CHECK_* and .*_OVERFLOW into fold...
Jakub Jelinek [Thu, 15 Jun 2023 06:49:27 +0000 (08:49 +0200)]
middle-end: Move constant args folding of .UBSAN_CHECK_* and .*_OVERFLOW into fold-const-call.cc

Here is an incremental patch to handle constant folding of these
in fold-const-call.cc rather than gimple-fold.cc.
Not really sure if that is the way to go because it is replacing 28
lines of former code with 65 of new code, for the overall benefit that say
int
foo (long long *p)
{
  int one = 1;
  long long max = __LONG_LONG_MAX__;
  return __builtin_add_overflow (one, max, p);
}
can be now fully folded already in ccp1 pass while before it was only
cleaned up in forwprop1 pass right after it.

On Wed, Jun 14, 2023 at 12:25:46PM +0000, Richard Biener wrote:
> I think that's still very much desirable so this followup looks OK.
> Maybe you can re-base it as prerequesite though?

Rebased then (of course with the UADDC/USUBC handling removed from this
first patch, will be added in the second one).

2023-06-15  Jakub Jelinek  <jakub@redhat.com>

* gimple-fold.cc (gimple_fold_call): Move handling of arg0
as well as arg1 INTEGER_CSTs for .UBSAN_CHECK_{ADD,SUB,MUL}
and .{ADD,SUB,MUL}_OVERFLOW calls from here...
* fold-const-call.cc (fold_const_call): ... here.

13 months agoAArch64: New RTL for ABD
Oluwatamilore Adebayo [Thu, 15 Jun 2023 06:36:48 +0000 (07:36 +0100)]
AArch64: New RTL for ABD

This patch adds new RTL and tests for sabd and uabd

PR tree-optimization/109156

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (aarch64_<su>abd<mode>):
Rename to <su>abd<mode>3.
* config/aarch64/aarch64-sve.md (<su>abd<mode>_3): Rename
to <su>abd<mode>3.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/abd.h: New file.
* gcc.target/aarch64/abd_2.c: New test.
* gcc.target/aarch64/abd_3.c: New test.
* gcc.target/aarch64/abd_4.c: New test.
* gcc.target/aarch64/abd_none_2.c: New test.
* gcc.target/aarch64/abd_none_3.c: New test.
* gcc.target/aarch64/abd_none_4.c: New test.
* gcc.target/aarch64/abd_run_1.c: New test.
* gcc.target/aarch64/sve/abd_1.c: New test.
* gcc.target/aarch64/sve/abd_none_1.c: New test.
* gcc.target/aarch64/sve/abd_2.c: New test.
* gcc.target/aarch64/sve/abd_none_2.c: New test.

13 months agoMissed opportunity to use [SU]ABD
Oluwatamilore Adebayo [Thu, 15 Jun 2023 06:36:48 +0000 (07:36 +0100)]
Missed opportunity to use [SU]ABD

This adds a recognition pattern for the non-widening
absolute difference (ABD).

gcc/ChangeLog:

* doc/md.texi (sabd, uabd): Document them.
* internal-fn.def (ABD): Use new optab.
* optabs.def (sabd_optab, uabd_optab): New optabs,
* tree-vect-patterns.cc (vect_recog_absolute_difference):
Recognize the following idiom abs (a - b).
(vect_recog_sad_pattern): Refactor to use
vect_recog_absolute_difference.
(vect_recog_abd_pattern): Use patterns found by
vect_recog_absolute_difference to build a new ABD
internal call.

13 months agoLoongArch: Change the default value of LARCH_CALL_RATIO to 6.
chenxiaolong [Thu, 15 Jun 2023 02:46:24 +0000 (02:46 +0000)]
LoongArch: Change the default value of LARCH_CALL_RATIO to 6.

During the regression testing of the LoongArch architecture GCC, it was found
that the tests in the pr90883.C file failed. The problem was modulated and
found that the error was caused by setting the macro LARCH_CALL_RATIO to a too
large value. Combined with the actual LoongArch architecture, the different
thresholds for meeting the test conditions were tested using the engineering method
(SPEC CPU 2006), and the results showed that its optimal threshold should be set
to 6.

gcc/ChangeLog:

* config/loongarch/loongarch.h (LARCH_CALL_RATIO): Modify the value
of macro LARCH_CALL_RATIO on LoongArch to make it perform optimally.

13 months agoRISC-V: Use merge approach to optimize vector permutation
Juzhe-Zhong [Wed, 14 Jun 2023 04:24:09 +0000 (12:24 +0800)]
RISC-V: Use merge approach to optimize vector permutation

This patch is to optimize the permuation case that is suiteable use
merge approach.

Consider this following case:
typedef int8_t vnx16qi __attribute__((vector_size (16)));

void __attribute__ ((noipa))
merge0 (vnx16qi x, vnx16qi y, vnx16qi *out)
{
  vnx16qi v = __builtin_shufflevector ((vnx16qi) x, (vnx16qi) y, MASK_16);
  *(vnx16qi*)out = v;
}

The gimple IR:
v_3 = VEC_PERM_EXPR <x_1(D), y_2(D), { 0, 17, 2, 19, 4, 21, 6, 23, 8, 9, 10, 27, 12, 29, 14, 31 }>;

Selector = { 0, 17, 2, 19, 4, 21, 6, 23, 8, 9, 10, 27, 12, 29, 14, 31 }, the common expression:
{ 0, nunits + 1, 2, nunits + 3, 4, nunits + 5, ...  }

For this selector, we can use vmsltu + vmerge to optimize the codegen.

Before this patch:
merge0:
        addi    a5,sp,16
        vl1re8.v        v3,0(a5)
        li      a5,31
        vsetivli        zero,16,e8,m1,ta,mu
        vmv.v.x v2,a5
        lui     a5,%hi(.LANCHOR0)
        addi    a5,a5,%lo(.LANCHOR0)
        vl1re8.v        v1,0(a5)
        vl1re8.v        v4,0(sp)
        vand.vv v1,v1,v2
        vmsgeu.vi       v0,v1,16
        vrgather.vv     v2,v4,v1
        vadd.vi v1,v1,-16
        vrgather.vv     v2,v3,v1,v0.t
        vs1r.v  v2,0(a0)
        ret

After this patch:
merge0:
        addi    a5,sp,16
        vl1re8.v        v1,0(a5)
        lui     a5,%hi(.LANCHOR0)
        addi    a5,a5,%lo(.LANCHOR0)
        vsetivli        zero,16,e8,m1,ta,ma
        vl1re8.v        v0,0(a5)
        vl1re8.v        v2,0(sp)
        vmsltu.vi       v0,v0,16
        vmerge.vvm      v1,v1,v2,v0
        vs1r.v  v1,0(a0)
        ret

The key of this optimization is that:
1. mask = vmsltu (selector, nunits)
2. result = vmerge (op0, op1, mask)

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_merge_patterns): New pattern.
(expand_vec_perm_const_1): Add merge optmization.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge-7.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/merge_run-7.c: New test.

13 months agoRISC-V: Ensure vector args and return use function stack to pass [PR110119]
Lehua Ding [Wed, 14 Jun 2023 11:56:11 +0000 (19:56 +0800)]
RISC-V: Ensure vector args and return use function stack to pass [PR110119]

The V2 patch address comments from Juzhe, thanks.

Hi,

The reason for this bug is that in the case where the vector register is set
to a fixed length (with `--param=riscv-autovec-preference=fixed-vlmax` option),
TARGET_PASS_BY_REFERENCE thinks that variables of type vint32m1 can be passed
through two scalar registers, but when GCC calls FUNCTION_VALUE (call function
riscv_get_arg_info inside) it returns NULL_RTX. These two functions are not
unified. The current treatment is to pass all vector arguments and returns
through the function stack, and a new calling convention for vector registers
will be added in the future.

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/
https://github.com/palmer-dabbelt/riscv-elf-psabi-doc/commit/126fa719972ff998a8a239c47d506c7809aea363

Best,
Lehua

gcc/ChangeLog:
PR target/110119
* config/riscv/riscv.cc (riscv_get_arg_info): Return NULL_RTX for vector mode
(riscv_pass_by_reference): Return true for vector mode

gcc/testsuite/ChangeLog:
PR target/110119
* gcc.target/riscv/rvv/base/pr110119-1.c: New test.
* gcc.target/riscv/rvv/base/pr110119-2.c: New test.

13 months agoRISC-V: Align the predictor style for define_insn_and_split
Pan Li [Wed, 14 Jun 2023 02:10:44 +0000 (10:10 +0800)]
RISC-V: Align the predictor style for define_insn_and_split

This patch is considered as the follow up of the below PATCH.

https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621347.html

We aligned the predictor style for the define_insn_and_split suggested
by Kito. To avoid potential issues before we hit.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/ChangeLog:

* config/riscv/autovec-opt.md: Align the predictor sytle.
* config/riscv/autovec.md: Ditto.

13 months agoRISC-V: Bugfix for vec_init repeating auto vectorization in RV32
Pan Li [Tue, 13 Jun 2023 15:19:14 +0000 (23:19 +0800)]
RISC-V: Bugfix for vec_init repeating auto vectorization in RV32

When constructing a vector mask from individual elements we wrongly
assumed that we can broadcast BITS_PER_WORD (i.e. XLEN).  The maximum is
actually the vector element length (i.e. ELEN).  This patch fixes this.

After this patch, below failures on RV32 will be fixed.

FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test
FAIL: gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-2.c execution test
FAIL: gcc.target/riscv/rvv/autovec/vls-vlmax/repeat_run-3.c -std=c99 -O3 -ftree-vectorize --param riscv-autovec-preference=fixed-vlmax execution test

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/ChangeLog:

* config/riscv/riscv-v.cc (rvv_builder::get_merge_scalar_mask):
Take elen instead of scalar BITS_PER_WORD.
(expand_vector_init_merge_repeating_sequence): Use inner_bits_size
instead of scaler BITS_PER_WORD.

13 months agoDaily bump.
GCC Administrator [Thu, 15 Jun 2023 00:16:35 +0000 (00:16 +0000)]
Daily bump.

13 months agoRemove MFWRAP_SPEC remnant
Jivan Hakobyan [Wed, 14 Jun 2023 18:43:35 +0000 (12:43 -0600)]
Remove MFWRAP_SPEC remnant

This patch removes a remnant of mudflap.

gcc/ChangeLog:
* config/moxie/uclinux.h (MFWRAP_SPEC): Remove

13 months agoMAINTAINERS: Add myself to write after approval
Filip Kastl [Wed, 14 Jun 2023 16:54:46 +0000 (18:54 +0200)]
MAINTAINERS: Add myself to write after approval

ChangeLog:

* MAINTAINERS: Add myself to write after approval

13 months agoaarch64: Fix -Werror=sign-compare bootstrap failure
Kyrylo Tkachov [Wed, 14 Jun 2023 16:08:03 +0000 (17:08 +0100)]
aarch64: Fix -Werror=sign-compare bootstrap failure

Pushing to fix bootstrap.

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-base.cc (svlast_impl::fold):
Fix signed comparison warning in loop from npats to enelts.

13 months ago[contrib] validate_failures.py: Ignore stray filesystem paths in results
Maxim Kuvyrkov [Fri, 2 Jun 2023 14:51:40 +0000 (14:51 +0000)]
[contrib] validate_failures.py: Ignore stray filesystem paths in results

This patch simplifies comparison of results that have filesystem
paths.  E.g., (assuming different values of <N>):
<cut>
Running /home/user/gcc-N/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp ...
ERROR: tcl error sourcing /home/user/gcc-N/gcc/testsuite/gcc.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp.
</cut>

We add "--srcpath <regex>", option, and set it by default to
"[^ ]+/testsuite/", which works well for all components of the GNU
Toolchain.  We then remove substrings matching <regex> from paths of
.exp files and from occasional "ERROR:" results.

contrib/ChangeLog:

* testsuite-management/validate_failures.py (TestResult,)
(ParseManifestWorker, ParseSummary, Main): Handle new option
"--srcpath <regex>".

13 months ago[contrib] validate_failures.py: Add "--expiry_date YYYYMMDD" option
Maxim Kuvyrkov [Thu, 25 May 2023 12:18:30 +0000 (12:18 +0000)]
[contrib] validate_failures.py: Add "--expiry_date YYYYMMDD" option

This option sets "today" date to compare expiration entries against.
Setting expiration date into the future allows re-detection of flaky
tests and creating fresh entries for them before the current flaky
entries expire.

contrib/ChangeLog:

* testsuite-management/validate_failures.py (TestResult): Update.
(Main): Handle new option "--expiry_date YYYYMMDD".

13 months ago[contrib] validate_failures.py: Add new option --invert_match
Maxim Kuvyrkov [Wed, 3 May 2023 15:53:17 +0000 (15:53 +0000)]
[contrib] validate_failures.py: Add new option --invert_match

This option is used to detect flaky tests that FAILed in the clean
build (or manifest), but PASSed in the current build (or manifest).

The option inverts output logic similar to what "-v/--invert-match"
does for grep.

contrib/ChangeLog:

* testsuite-management/validate_failures.py (ResultSet.update,)
(ResultSet.HasTestsuite): New methods.
(GetResults): Update.
(ParseSummary, CompareResults, PerformComparison, Main): Handle new
option --invert_match.

13 months ago[contrib] validate_failures.py: Improve error output
Thiago Bauermann [Thu, 1 Jun 2023 12:25:18 +0000 (12:25 +0000)]
[contrib] validate_failures.py: Improve error output

- Print message in case of broken sum file error.
- Print error messages to stderr.  The script's stdout is, usually,
  redirected to a file, and error messages shouldn't go there.

contrib/ChangeLog:

* testsuite-management/validate_failures.py (TestResult): Improve error
output.

13 months ago[contrib] validate_failures.py: Support "$tool:" prefix in exp names
Christophe Lyon [Thu, 1 Jun 2023 12:00:48 +0000 (12:00 +0000)]
[contrib] validate_failures.py: Support "$tool:" prefix in exp names

This makes it easier to extract the $tool:$exp pair when iterating
over failures/flaky tests, which, in turn, simplifies re-running
testsuite parts that have unexpected failures or passes.

contrib/ChangeLog:

* testsuite-management/validate_failures.py (_EXP_LINE_FORMAT,)
(_EXP_LINE_REX, ResultSet): Support "$tool:" prefix in exp names.

13 months ago[contrib] validate_failures.py: Use exit code "2" to indicate regression
Maxim Kuvyrkov [Mon, 30 Aug 2021 14:18:09 +0000 (14:18 +0000)]
[contrib] validate_failures.py: Use exit code "2" to indicate regression

... in the results.  Python exits with code "1" on exceptions and
internal errors, which we use to detect failure to parse results.

contrib/ChangeLog:

* testsuite-management/validate_failures.py (Main): Use exit code "2"
to indicate regression.

13 months ago[contrib] validate_failures.py: Be more stringent in parsing result lines
Maxim Kuvyrkov [Thu, 1 Jun 2023 12:05:08 +0000 (12:05 +0000)]
[contrib] validate_failures.py: Be more stringent in parsing result lines

Before this patch we would identify malformed line
"UNRESOLVEDTest run by tcwg-buildslave on Mon Aug 23 10:17:50 2021"
as an interesting result, only to fail in TestResult:__init__ due
to missing ":" after UNRESOLVED.

This patch makes all places that parse result lines use a single
compiled regex.

contrib/ChangeLog:

* testsuite-management/validate_failures.py (_VALID_TEST_RESULTS_REX):
Update.
(TestResult): Use _VALID_TEST_RESULTS_REX.

13 months ago[contrib] validate_failures.py: Add more verbosity levels
Maxim Kuvyrkov [Mon, 12 Jul 2021 15:41:47 +0000 (15:41 +0000)]
[contrib] validate_failures.py: Add more verbosity levels

... to control validate_failures.py output

contrib/ChangeLog:

* testsuite-management/validate_failures.py: Add more verbosity levels.

13 months ago[contrib] validate_failures.py: Simplify GetManifestPath()
Maxim Kuvyrkov [Thu, 8 Jul 2021 08:27:39 +0000 (08:27 +0000)]
[contrib] validate_failures.py: Simplify GetManifestPath()

... and don't require a valid build directory when no data from it
is necessary.

contrib/ChangeLog:

* testsuite-management/validate_failures.py: Simplify GetManifestPath().

13 months ago[contrib] validate_failures.py: Read in manifest when comparing build dirs
Maxim Kuvyrkov [Thu, 8 Jul 2021 08:21:18 +0000 (08:21 +0000)]
[contrib] validate_failures.py: Read in manifest when comparing build dirs

This allows comparison of two build directories with a manifest
listing known flaky tests on the side.

contrib/ChangeLog:

* testsuite-management/validate_failures.py (GetResults): Update.
(CompareBuilds): Read in manifest.

13 months ago[contrib] validate_failures.py: Support expiry attributes in manifests
Maxim Kuvyrkov [Wed, 12 Apr 2023 14:35:39 +0000 (14:35 +0000)]
[contrib] validate_failures.py: Support expiry attributes in manifests

contrib/ChangeLog:

* testsuite-management/validate_failures.py (ParseManifestWorker):
Support expiry attributes in manifests.
(ParseSummary): Add a comment.

13 months ago[contrib] validate_failures.py: Avoid testsuite aliasing
Maxim Kuvyrkov [Thu, 1 Jun 2023 12:27:51 +0000 (12:27 +0000)]
[contrib] validate_failures.py: Avoid testsuite aliasing

This patch adds tracking of current testsuite "tool" and "exp"
to the processing of .sum files.  This avoids aliasing between
tests from different testsuites with same name+description.

E.g., this is necessary for testsuite/c-c++-common, which is ran
for both gcc and g++ "tools".

This patch changes manifest format from ...
<cut>
FAIL: gcc_test
FAIL: g++_test
</cut>
... to ...
<cut>
=== gcc tests ===
Running gcc/foo.exp ...
FAIL: gcc_test
=== gcc Summary ==
=== g++ tests ===
Running g++/bar.exp ...
FAIL: g++_test
=== g++ Summary ==
</cut>.

The new format uses same formatting as DejaGnu's .sum files
to specify which "tool" and "exp" the test belongs to.

contrib/ChangeLog:

* testsuite-management/validate_failures.py: Avoid testsuite
aliasing.

13 months agoc++: tweak c++17 ctor/conversion tiebreaker [DR2327]
Jason Merrill [Fri, 3 Mar 2023 20:04:25 +0000 (15:04 -0500)]
c++: tweak c++17 ctor/conversion tiebreaker [DR2327]

In discussion of this issue CWG decided that the change of behavior on
well-formed code like overload-conv-4.C is undesirable.  In further
discussion of possible resolutions, we discovered that we can avoid that
change while still getting the desired behavior on overload-conv-3.C by
making this a tiebreaker after comparing conversions, rather than before.
This also simplifies the implementation.

The issue resolution has not yet been finalized, but this seems like a clear
improvement.

DR 2327
PR c++/86521

gcc/cp/ChangeLog:

* call.cc (joust_maybe_elide_copy): Don't change cand.
(joust): Move the elided tiebreaker later.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/overload-conv-4.C: Remove warnings.
* g++.dg/cpp1z/elide7.C: New test.

13 months agolibstdc++: Clarify manual demangle doc
Jonny Grant [Sat, 10 Jun 2023 22:03:40 +0000 (23:03 +0100)]
libstdc++: Clarify manual demangle doc

libstdc++-v3/ChangeLog:

* doc/xml/manual/extensions.xml: Remove demangle exception
description and include.
* doc/html/manual/ext_demangling.html: Regenerate.

13 months agoAlign a 'OMP_TARGET_OFFLOAD=mandatory' diagnostic with others
Thomas Schwinge [Wed, 14 Jun 2023 10:44:05 +0000 (12:44 +0200)]
Align a 'OMP_TARGET_OFFLOAD=mandatory' diagnostic with others

On 2023-06-14T11:42:22+0200, Tobias Burnus <tobias@codesourcery.com> wrote:
> On 14.06.23 10:09, Thomas Schwinge wrote:
>> Let me know if I should also adjust the new 'target { ! offload_device }'
>> diagnostic "[...] MANDATORY but only the host device is available" to
>> include a comma before 'but', for consistency with the other existing
>> diagnostics (cited above)?
>
> I think it makes sense to be consistent. Thus: Yes, please add the commas.

Fix-up for recent commit 18c8b56c7d67a9e37acf28822587786f0fc0efbc
"OpenMP: Set default-device-var with OMP_TARGET_OFFLOAD=mandatory".

libgomp/
* target.c (resolve_device): Align a
'OMP_TARGET_OFFLOAD=mandatory' diagnostic with others.
* testsuite/libgomp.c/target-51.c: Adjust.

13 months agodriver: Forward '-lgfortran', '-lm' to offloading compilation
Thomas Schwinge [Mon, 5 Jun 2023 09:26:37 +0000 (11:26 +0200)]
driver: Forward '-lgfortran', '-lm' to offloading compilation

..., so that users don't manually need to specify
'-foffload-options=-lgfortran', '-foffload-options=-lm' in addition to
'-lgfortran', '-lm' (specified manually, or implicitly by the driver).

gcc/
* gcc.cc (driver_handle_option): Forward host '-lgfortran', '-lm'
to offloading compilation.
* config/gcn/mkoffload.cc (main): Adjust.
* config/nvptx/mkoffload.cc (main): Likewise.
* doc/invoke.texi (foffload-options): Update example.
libgomp/
* testsuite/libgomp.fortran/fortran.exp (lang_link_flags): Don't
set.
* testsuite/libgomp.oacc-fortran/fortran.exp (lang_link_flags):
Likewise.
* testsuite/libgomp.c/simd-math-1.c: Remove
'-foffload-options=-lm'.
* testsuite/libgomp.fortran/fortran-torture_execute_math.f90:
Likewise.
* testsuite/libgomp.oacc-fortran/fortran-torture_execute_math.f90:
Likewise.

13 months agoAdd 'libgomp.{,oacc-}fortran/fortran-torture_execute_math.f90'
Thomas Schwinge [Fri, 2 Jun 2023 21:11:00 +0000 (23:11 +0200)]
Add 'libgomp.{,oacc-}fortran/fortran-torture_execute_math.f90'

..., via 'include'ing the existing 'gfortran.fortran-torture/execute/math.f90',
which therefore is enhanced for optional OpenACC 'serial', OpenMP 'target'
usage.

gcc/testsuite/
* gfortran.fortran-torture/execute/math.f90: Enhance for optional
OpenACC 'serial', OpenMP 'target' usage.
libgomp/
* testsuite/libgomp.fortran/fortran-torture_execute_math.f90: New.
* testsuite/libgomp.oacc-fortran/fortran-torture_execute_math.f90:
Likewise.

13 months agoTighten 'dg-warning' alternatives in 'c-c++-common/Wfree-nonheap-object{,-2,-3}.c'
Thomas Schwinge [Wed, 7 Jun 2023 14:24:26 +0000 (16:24 +0200)]
Tighten 'dg-warning' alternatives in 'c-c++-common/Wfree-nonheap-object{,-2,-3}.c'

..., added in commit fe7f75cf16783589eedbab597e6d0b8d35d7e470
"Correct/improve maybe_emit_free_warning (PR middle-end/98166, PR c++/57111, PR middle-end/98160)".

These use alternatives like, for example, "AB|CDE|FG", but what really must've
been meant is "A(B|C)D(E|F)G".  The former variant also does "work": it matches
any of "AB", or "CDE", or "FG", which are components of the latter variant.
(That means, the former variant matches too loosely.)

gcc/testsuite/
* c-c++-common/Wfree-nonheap-object-2.c: Tighten 'dg-warning'
alternatives.
* c-c++-common/Wfree-nonheap-object-3.c: Likewise.
* c-c++-common/Wfree-nonheap-object.c: Likewise.

13 months agoRemove 'gcc/testsuite/g++.dg/warn/Wfree-nonheap-object.s'
Thomas Schwinge [Wed, 7 Jun 2023 14:01:39 +0000 (16:01 +0200)]
Remove 'gcc/testsuite/g++.dg/warn/Wfree-nonheap-object.s'

..., which, presumably, was added by mistake in
commit dce6c58db87ebf7f4477bd3126228e73e4eeee97
"Add support for detecting mismatched allocation/deallocation calls".

gcc/testsuite/
* g++.dg/warn/Wfree-nonheap-object.s: Remove.

13 months agoFix typo in 'libgomp.c/target-51.c'
Thomas Schwinge [Wed, 14 Jun 2023 07:25:15 +0000 (09:25 +0200)]
Fix typo in 'libgomp.c/target-51.c'

..., and therefore, given 'target offload_device':

    PASS: libgomp.c/target-51.c (test for excess errors)
    PASS: libgomp.c/target-51.c execution test
    [-FAIL:-]{+PASS:+} libgomp.c/target-51.c output pattern test

Fix-up for recent commit 18c8b56c7d67a9e37acf28822587786f0fc0efbc
"OpenMP: Set default-device-var with OMP_TARGET_OFFLOAD=mandatory".

libgomp/
* testsuite/libgomp.c/target-51.c: Fix typo.

13 months agoUse x instead of v for alternative 2 (v, BH) in mov<mode>_internal.
liuhongt [Tue, 13 Jun 2023 06:20:59 +0000 (14:20 +0800)]
Use x instead of v for alternative 2 (v, BH) in mov<mode>_internal.

Since there's no evex version for vpcmpeq ymm, ymm, ymm.

gcc/ChangeLog:

PR target/110227
* config/i386/sse.md (mov<mode>_internal>): Use x instead of v
for alternative 2 since there's no evex version for vpcmpeqd
ymm, ymm, ymm.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr110227.c: New test.

13 months agoOpenMP: Set default-device-var with OMP_TARGET_OFFLOAD=mandatory
Tobias Burnus [Wed, 14 Jun 2023 05:53:02 +0000 (07:53 +0200)]
OpenMP: Set default-device-var with OMP_TARGET_OFFLOAD=mandatory

OMP_TARGET_OFFLOAD=mandatory handling was before inconsistent. Hence, in
OpenMP 5.2 it was clarified/extended by having implications on the
default-device-var; additionally, omp_initial_device and omp_invalid_device
enum values/PARAMETERs were added; support for it was added
in r13-1066-g1158fe43407568 including aborting for omp_invalid_device and
non-conforming device numbers. Only the mandatory handling was missing.

Namely, while the default-device-var is usually initialized to value 0,
with 'mandatory' it must have the value 'omp_invalid_device' if and only if
zero non-host devices are available. (The OMP_DEFAULT_DEVICE env var
overrides this as it comes semantically after the initialization.)

To achieve this, default-device-var is now initialized to MIN_INT. If
there is no 'mandatory', it is set to 0 directly after env var parsing.
Otherwise, it is updated in gomp_target_init to either 0 or
omp_invalid_device. To ensure INT_MIN is never seen by the user, both
the omp_get_default_device API routine and omp_display_env (user call
and OMP_DISPLAY_ENV env var) call gomp_init_targets_once() in that case.

libgomp/ChangeLog:

* env.c (gomp_default_icv_values): Init default_device_var to
an nonconforming value - INT_MIN.
(initialize_env): After env-var parsing, set default_device_var to
device 0 unless OMP_TARGET_OFFLOAD=mandatory.
(omp_display_env): If default_device_var is INT_MIN, call
gomp_init_targets_once.
* icv-device.c (omp_get_default_device): Likewise.
* libgomp.texi (OMP_DEFAULT_DEVICE): Update init description.
(OpenMP 5.2 Impl. Status): Mark OMP_TARGET_OFFLOAD=mandatory as 'Y'.
* target.c (resolve_device): Improve error message device-num < 0
with 'mandatory' and no no-host devices available.
(gomp_target_init): Set default-device-var if INT_MIN.
* testsuite/libgomp.c/target-48.c: New test.
* testsuite/libgomp.c/target-49.c: New test.
* testsuite/libgomp.c/target-50.c: New test.
* testsuite/libgomp.c/target-50a.c: New test.
* testsuite/libgomp.c/target-51.c: New test.
* testsuite/libgomp.c/target-52.c: New test.
* testsuite/libgomp.c/target-53.c: New test.
* testsuite/libgomp.c/target-54.c: New test.

13 months agoDaily bump.
GCC Administrator [Wed, 14 Jun 2023 00:17:28 +0000 (00:17 +0000)]
Daily bump.

13 months agomodula2 Fixes to the error format specifications
Gaius Mulley [Tue, 13 Jun 2023 22:21:42 +0000 (23:21 +0100)]
modula2 Fixes to the error format specifications

This patch contains a python3 script to check the meta format error
specifications.  It also includes about 20 fixes to M2Quads.mod format
specifications.

gcc/m2/ChangeLog:

* Make-lang.in (check-format-error): New rule.
* gm2-compiler/M2MetaError.mod (op): Add calls InternalError if
digits are detected.
* gm2-compiler/M2Quads.mod (BuildForToByDo): Bugfix to format
specifier.
(BuildLengthFunction): Bugfix to format specifiers.
(BuildOddFunction): Bugfix to format specifiers.
(BuildAbsFunction): Bugfix to format specifiers.
(BuildCapFunction): Bugfix to format specifiers.
(BuildChrFunction): Bugfix to format specifiers.
(BuildOrdFunction): Bugfix to format specifiers.
(BuildMakeAdrFunction): Bugfix to format specifiers.
(BuildSizeFunction): Bugfix to format specifiers.
(BuildBitSizeFunction): Bugfix to format specifiers.
* tools-src/checkmeta.py: New file.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
13 months agoc/c++: use positive tone in missing header notes [PR84890]
David Malcolm [Tue, 13 Jun 2023 21:42:47 +0000 (17:42 -0400)]
c/c++: use positive tone in missing header notes [PR84890]

Quoting "How a computer should talk to people" (as quoted
in "Concepts Error Messages for Humans"):

"Various negative tones or actions are unfriendly: being manipulative,
not giving a second chance, talking down, using fashionable slang,
blaming. We must not seem to blame the person. We should avoid suggesting
that the person is inadequate. Phrases like "you forgot" may seem
harmless, but what if a computer said this to you four or five times in
two minutes? Anyway, the person may disagree, so why risk offense?"

gcc/c-family/ChangeLog:
PR c/84890
* known-headers.cc
(suggest_missing_header::~suggest_missing_header): Reword note to
avoid negative tone of "forgetting".

gcc/cp/ChangeLog:
PR c/84890
* name-lookup.cc (missing_std_header::~missing_std_header): Reword
note to avoid negative tone of "forgetting".

gcc/testsuite/ChangeLog:
PR c/84890
* g++.dg/cpp2a/srcloc3.C: Update expected message.
* g++.dg/lookup/missing-std-include-2.C: Likewise.
* g++.dg/lookup/missing-std-include-3.C: Likewise.
* g++.dg/lookup/missing-std-include-6.C: Likewise.
* g++.dg/lookup/missing-std-include.C: Likewise.
* g++.dg/spellcheck-inttypes.C: Likewise.
* g++.dg/spellcheck-stdint.C: Likewise.
* g++.dg/spellcheck-stdlib.C: Likewise.
* gcc.dg/spellcheck-inttypes.c: Likewise.
* gcc.dg/spellcheck-stdbool.c: Likewise.
* gcc.dg/spellcheck-stdint.c: Likewise.
* gcc.dg/spellcheck-stdlib.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
13 months agoc++: Fix templated convertion operator demangling
Nathan Sidwell [Mon, 12 Jun 2023 23:37:04 +0000 (19:37 -0400)]
c++: Fix templated convertion operator demangling

Instantiations of templated conversion operators failed to demangle
for cases such as 'operator X<int>', but worked for 'operator X<int>
&', due to thinking the template instantiation of X was the
instantiation of the conversion operator itself.

libiberty/
* cp-demangle.c (d_print_conversion): Remove incorrect
template instantiation handling.
* testsuite/demangle-expected: Add testcases.

13 months agoFortran: add DATA statement testcase
Francois-Xavier Coudert [Tue, 13 Jun 2023 18:09:23 +0000 (20:09 +0200)]
Fortran: add DATA statement testcase

gcc/testsuite/
* gfortran.dg/data_array_7.f90: New test.

13 months agoFortran: fix passing of zero-sized array arguments to procedures [PR86277]
Harald Anlauf [Mon, 12 Jun 2023 21:08:48 +0000 (23:08 +0200)]
Fortran: fix passing of zero-sized array arguments to procedures [PR86277]

gcc/fortran/ChangeLog:

PR fortran/86277
* trans-array.cc (gfc_trans_allocate_array_storage): When passing a
zero-sized array with fixed (= non-dynamic) size, allocate temporary
by the caller, not by the callee.

gcc/testsuite/ChangeLog:

PR fortran/86277
* gfortran.dg/zero_sized_14.f90: New test.
* gfortran.dg/zero_sized_15.f90: New test.

Co-authored-by: Mikael Morin <mikael@gcc.gnu.org>
13 months agoRemove a couple mudflap remnants
Jeff Law [Tue, 13 Jun 2023 17:46:32 +0000 (11:46 -0600)]
Remove a couple mudflap remnants

I happened to be digging into the specs to understand a build
failure and spotted mflib and mfwrap.  Those were used by the
mudflap system which we ripped out years ago and we just missed
these.

I verified x86 still bootstraps after removing these bits.

Pushed to the trunk as obvious,
gcc/
* gcc.cc (LINK_COMMAND_SPEC): Remove mudflap spec handling.

13 months agoRemove sh5media divtab code
Jeff Law [Tue, 13 Jun 2023 17:10:21 +0000 (11:10 -0600)]
Remove sh5media divtab code

Spurred by Akari Takahashi's patch to config/sh/divtab.cc, this removes
divtab.cc completely.

divtab.cc was used to calculate a division table for the sh5 media
processor.  GCC dropped support for that (unmanufactured) chip back
in 2016 and this file simply got missed AFAICT.

gcc/
* config/sh/divtab.cc: Remove.

13 months agoi386: Fix up whitespace in assembly
Jakub Jelinek [Tue, 13 Jun 2023 16:39:45 +0000 (18:39 +0200)]
i386: Fix up whitespace in assembly

I've noticed that standard_sse_constant_opcode emits some spurious
whitespace around tab, that isn't something which is done for
any other instruction and looks wrong.

2023-06-13  Jakub Jelinek  <jakub@redhat.com>

* config/i386/i386.cc (standard_sse_constant_opcode): Remove
superfluous spaces around \t for vpcmpeqd.

13 months agoAvoid duplicate vector initializations during RTL expansion.
Roger Sayle [Tue, 13 Jun 2023 16:20:31 +0000 (17:20 +0100)]
Avoid duplicate vector initializations during RTL expansion.

This middle-end patch avoids some redundant RTL for vector initialization
during RTL expansion.  For the simple test case:

typedef __int128 v1ti __attribute__ ((__vector_size__ (16)));
__int128 key;

v1ti foo() {
    return (v1ti){key};
}

the middle-end currently expands:

(set (reg:V1TI 85) (const_vector:V1TI [ (const_int 0) ]))

(set (reg:V1TI 85) (mem/c:V1TI (symbol_ref:DI ("key"))))

where we create a dead instruction that initializes the vector to zero,
immediately followed by a set of the entire vector.  This patch skips
this zeroing instruction when the vector has only a single element.
It also updates the code to indicate when we've cleared the vector,
so that we don't need to initialize zero elements.

2023-06-13  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* expr.cc (store_constructor) <case VECTOR_TYPE>: Don't bother
clearing vectors with only a single element.  Set CLEARED if the
vector was initialized to zero.

13 months agoRISC-V: Remove duplicate `#include "riscv-vector-switch.def"`
Lehua Ding [Tue, 13 Jun 2023 10:59:09 +0000 (18:59 +0800)]
RISC-V: Remove duplicate `#include "riscv-vector-switch.def"`

Hi,

This patch remove the duplicate `#include "riscv-vector-switch.def"` statement
and add #undef for ENTRY and TUPLE_ENTRY macros later.

Best,
Lehua

gcc/ChangeLog:

* config/riscv/riscv-v.cc (struct mode_vtype_group): Remove duplicate
#include.
(ENTRY): Undef.
(TUPLE_ENTRY): Undef.

13 months agoRISC-V: Add comments of some functions
Juzhe-Zhong [Tue, 13 Jun 2023 02:26:11 +0000 (10:26 +0800)]
RISC-V: Add comments of some functions

gcc/ChangeLog:

* config/riscv/riscv-v.cc (rvv_builder::single_step_npatterns_p): Add comment.
(shuffle_generic_patterns): Ditto.
(expand_vec_perm_const_1): Ditto.

13 months agoRISC-V: Add more SLP tests
Juzhe-Zhong [Tue, 13 Jun 2023 11:38:38 +0000 (19:38 +0800)]
RISC-V: Add more SLP tests

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/slp-10.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp-11.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp-13.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp-14.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp-15.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp_run-10.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp_run-11.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp_run-13.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp_run-14.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp_run-15.c: New test.

13 months agoRISC-V: Fix bug of VLA SLP auto-vectorization
Juzhe-Zhong [Tue, 13 Jun 2023 09:30:55 +0000 (17:30 +0800)]
RISC-V: Fix bug of VLA SLP auto-vectorization

Sorry for producing bugs in the previous VLA SLP patch.

Consider this following permutation:
_85 = VEC_PERM_EXPR <{ 99, 17, ... }, { 11, 80, ... }, { 0, POLY_INT_CST [4, 4], 1, POLY_INT_CST [5, 4], 2, POLY_INT_CST [6, 4], ... }>;

The correct result should be:
_85 = { 99, 11, 17, 80, ... }

However, I did wrong in the previous patch.

Code sequence before this patch:

set mask = { 0, 1, 0, 1, ... }
set v0 = { 99, 17, 99, 17, ... }
set v1 = { 11, 80, 11, 80, ... }
set index = viota (mask) = { 0, 0, 1, 1, 2, 2, ... }
set result = vrgather_mu (v0, v1, index, mask) = { 99, 11, 99, 80 }
The result is incorrect.

After this patch:

set mask = { 0, 1, 0, 1, ... }
set index = viota (mask) = { 0, 0, 1, 1, 2, 2, ... }
set v0 = vrgather ({ 99, 17, 99, 17, ... }, index) = { 99, 99, 17, 17, ... }
set v1 = { 11, 80, 11, 80, ... }
set result = vrgather_mu (v0, v1, index, mask) = { 99, 11, 17, 80 }
The result is what we expected.

This issue was discovered in the test I appended in this patch with --param=riscv-autovec-lmul=2.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (emit_vlmax_decompress_insn): Fix bug.
(shuffle_decompress_patterns): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/slp-12.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp_run-12.c: New test.

13 months agoFix memory leak in loop header copying
Richard Biener [Tue, 13 Jun 2023 10:39:46 +0000 (12:39 +0200)]
Fix memory leak in loop header copying

* tree-ssa-loop-ch.cc (ch_base::copy_headers): Free loop BBs.

13 months agoc++: mutable temps in rodata
Jason Merrill [Tue, 13 Jun 2023 11:29:34 +0000 (07:29 -0400)]
c++: mutable temps in rodata

If the type of a temporary has mutable members, we can't set TREE_READONLY
on the VAR_DECL; this is parallel to the check in
cp_apply_type_quals_to_decl.

gcc/cp/ChangeLog:

* tree.cc (build_target_expr): Check TYPE_HAS_MUTABLE_P.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/initlist-opt6.C: New test.

13 months agoRISC-V: Add vector psabi checking.
Yanzhang Wang [Tue, 13 Jun 2023 02:46:40 +0000 (10:46 +0800)]
RISC-V: Add vector psabi checking.

This patch adds support to check function's argument or return is vector type
and throw warning if yes.

There're two exceptions,
  - The vector_size attribute.
  - The intrinsic functions.

Some cases that need to add -Wno-psabi to ignore the warning.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (riscv_init_cumulative_args): Set
warning flag if func is not builtin
* config/riscv/riscv.cc
(riscv_scalable_vector_type_p): Determine whether the type is scalable vector.
(riscv_arg_has_vector): Determine whether the arg is vector type.
(riscv_pass_in_vector_p): Check the vector type param is passed by value.
(riscv_init_cumulative_args): The same as header.
(riscv_get_arg_info): Add the checking.
(riscv_function_value): Check the func return and set warning flag
* config/riscv/riscv.h (INIT_CUMULATIVE_ARGS): Add a flag to
determine whether warning psabi or not.

gcc/testsuite/ChangeLog:

* g++.target/riscv/rvv/base/pr109244.C: Add the -Wno-psabi.
* g++.target/riscv/rvv/base/pr109535.C: Same
* gcc.target/riscv/rvv/base/binop_vx_constraint-120.c: Same
* gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c: Same
* gcc.target/riscv/rvv/base/mask_insn_shortcut.c: Same
* gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c: Same
* gcc.target/riscv/rvv/base/pr110109-2.c: Same
* gcc.target/riscv/rvv/base/scalar_move-9.c: Same
* gcc.target/riscv/rvv/base/spill-10.c: Same
* gcc.target/riscv/rvv/base/spill-11.c: Same
* gcc.target/riscv/rvv/base/spill-9.c: Same
* gcc.target/riscv/rvv/base/vlmul_ext-1.c: Same
* gcc.target/riscv/rvv/base/zero_base_load_store_optimization.c: Same
* gcc.target/riscv/rvv/base/zvfh-intrinsic.c: Same
* gcc.target/riscv/rvv/base/zvfh-over-zvfhmin.c: Same
* gcc.target/riscv/rvv/base/zvfhmin-intrinsic.c: Same
* gcc.target/riscv/rvv/vsetvl/vsetvl-1.c: Same
* gcc.target/riscv/vector-abi-1.c: New test.
* gcc.target/riscv/vector-abi-2.c: New test.
* gcc.target/riscv/vector-abi-3.c: New test.
* gcc.target/riscv/vector-abi-4.c: New test.
* gcc.target/riscv/vector-abi-5.c: New test.
* gcc.target/riscv/vector-abi-6.c: New test.

Signed-off-by: Yanzhang Wang <yanzhang.wang@intel.com>
Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
13 months agolibgomp/testsuite: Add requires-unified-addr-1.{c,f90} [PR109837]
Tobias Burnus [Tue, 13 Jun 2023 09:27:47 +0000 (11:27 +0200)]
libgomp/testsuite: Add requires-unified-addr-1.{c,f90} [PR109837]

Add a testcase for 'omp requires unified_address' that is currently supported
by all devices but was not tested for.

libgomp/

PR libgomp/109837
* testsuite/libgomp.c-c++-common/requires-unified-addr-1.c: New test.
* testsuite/libgomp.fortran/requires-unified-addr-1.f90: New test.

13 months agoarm: Extend -mtp= arguments
Kyrylo Tkachov [Tue, 13 Jun 2023 09:17:24 +0000 (10:17 +0100)]
arm: Extend -mtp= arguments

After discussing the -mtp= option with Arm's LLVM developers we'd like to extend
the functionality of the option somewhat.
There are actually 3 system registers that can be accessed for the thread pointer
in aarch32: tpidrurw, tpidruro, tpidrprw.  They are all read through the CP15 co-processor
mechanism. The current -mtp=cp15 option reads the tpidruro register.
This patch extends -mtp to allow for the above three explicit tpidr names and
keeps -mtp=cp15 as an alias of -mtp=tpidruro for backwards compatibility.

Bootstrapped and tested on arm-none-linux-gnueabihf.

gcc/ChangeLog:

* config/arm/arm-opts.h (enum arm_tp_type): Remove TP_CP15.
Add TP_TPIDRURW, TP_TPIDRURO, TP_TPIDRPRW values.
* config/arm/arm-protos.h (arm_output_load_tpidr): Declare prototype.
* config/arm/arm.cc (arm_option_reconfigure_globals): Replace TP_CP15
with TP_TPIDRURO.
(arm_output_load_tpidr): Define.
* config/arm/arm.h (TARGET_HARD_TP): Define in terms of TARGET_SOFT_TP.
* config/arm/arm.md (load_tp_hard): Call arm_output_load_tpidr to output
assembly.
(reload_tp_hard): Likewise.
* config/arm/arm.opt (tpidrurw, tpidruro, tpidrprw): New values for
arm_tp_type.
* doc/invoke.texi (Arm Options, mtp): Document new values.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mtp.c: New test.
* gcc.target/arm/mtp_1.c: New test.
* gcc.target/arm/mtp_2.c: New test.
* gcc.target/arm/mtp_3.c: New test.
* gcc.target/arm/mtp_4.c: New test.

13 months agoaarch64: Extend -mtp= arguments
Kyrylo Tkachov [Tue, 13 Jun 2023 09:13:55 +0000 (10:13 +0100)]
aarch64: Extend -mtp= arguments

After discussing the -mtp= option with Arm's LLVM developers we'd like to extend
the functionality of the option somewhat.
First of all, there is another TPIDR register that can be used to read the thread pointer:
TPIDRRO_EL0 (which can also be accessed by AArch32 under another name) so it makes sense
to add -mtp=tpidrr0_el0. This makes the existing arguments el0, el1, el2, el3 somewhat
inconsistent in their naming so this patch introduces the more "full" names
tpidr_el0, tpidr_el1, tpidr_el2, tpidr_el3 and makes the above short names alias of these new ones.
Long story short, we preserve backwards compatibility and add a new TPIDR register to access through
-mtp that wasn't available previously.
There is more relevant discussion of the options at https://reviews.llvm.org/D152433 if you're interested.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

PR target/108779
* config/aarch64/aarch64-opts.h (enum aarch64_tp_reg): Add
AARCH64_TPIDRRO_EL0 value.
* config/aarch64/aarch64.cc (aarch64_output_load_tp): Define.
* config/aarch64/aarch64.opt (tpidr_el0, tpidr_el1, tpidr_el2,
tpidr_el3, tpidrro_el3): New accepted values to -mtp=.
* doc/invoke.texi (AArch64 Options): Document new -mtp= options.

gcc/testsuite/ChangeLog:

PR target/108779
* gcc.target/aarch64/mtp_5.c: New test.
* gcc.target/aarch64/mtp_6.c: New test.
* gcc.target/aarch64/mtp_7.c: New test.
* gcc.target/aarch64/mtp_8.c: New test.
* gcc.target/aarch64/mtp_9.c: New test.

13 months agofix frange_nextafter odr violation
Alexandre Oliva [Tue, 13 Jun 2023 08:52:22 +0000 (05:52 -0300)]
fix frange_nextafter odr violation

C++ requires inline functions to be declared inline and defined in
every translation unit that uses them.  frange_nextafter is used in
gimple-range-op.cc but it's only defined as inline in
range-op-float.cc.  Drop the extraneous inline specifier.

Other non-static inline functions in range-op-float.cc are not
referenced elsewhere, so I'm making them static.

for  gcc/ChangeLog

* range-op-float.cc (frange_nextafter): Drop inline.
(frelop_early_resolve): Add static.
(frange_float): Likewise.

13 months agomiddle-end/110232 - fix native interpret of vector <signed-boolean:1>
Richard Biener [Tue, 13 Jun 2023 07:19:34 +0000 (09:19 +0200)]
middle-end/110232 - fix native interpret of vector <signed-boolean:1>

The following fixes native interpretation of a buffer as boolean
vector with bit-precision elements such as AVX512 vectors.  The
check whether the buffer covers the whole vector was broken for
bit-precision elements and the following instead implements it
based on the vector type size.

PR middle-end/110232
* fold-const.cc (native_interpret_vector): Use TYPE_SIZE_UNIT
to check whether the buffer covers the whole vector.

* gcc.target/i386/pr110232.c: New testcase.

13 months agoFix disambiguation against .MASK_LOAD
Richard Biener [Tue, 13 Jun 2023 06:52:23 +0000 (08:52 +0200)]
Fix disambiguation against .MASK_LOAD

Alias analysis was treating .MASK_LOAD as storing a full vector
which means we disambiguate against decls of smaller than vector size.
This complements the previous patch handling .MASK_STORE and fixes
runtime execution FAILs of gfortran.dg/matmul_3.f90 and
gfortran.dg/inline_sum_2.f90 when using AVX512 with full masked loop
vectorization on Zen4.

* tree-ssa-alias.cc (ref_maybe_used_by_call_p_1): For
.MASK_LOAD and friends set the size of the access to unknown.

13 months agotestsuite: Update powerpc test fold-vec-extract-int.p8.c
“Ajit Kumar Agarwal” [Fri, 19 May 2023 07:30:44 +0000 (02:30 -0500)]
testsuite: Update powerpc test fold-vec-extract-int.p8.c

Update powerpc tests with extra zero_extend removal with default ree pass.

2023-06-13  Ajit Kumar Agarwal  <aagarwa1@linux.ibm.com>

gcc/testsuite/ChangeLog:

PR testsuite/109880
* gcc.target/powerpc/fold-vec-extract-int.p8.c: Update test.

13 months agotestsuite: Check int128 effective target for pr109932-{1,2}.c [PR110230]
Kewen Lin [Tue, 13 Jun 2023 08:04:54 +0000 (03:04 -0500)]
testsuite: Check int128 effective target for pr109932-{1,2}.c [PR110230]

This patch is to make newly added test cases pr109932-{1,2}.c
check int128 effective target to avoid unsupported type error
on 32-bit.  I did hit this failure during testing and fixed
it, but made a stupid mistake not updating the local formatted
patch which was actually out of date.

PR testsuite/110230
PR target/109932

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr109932-1.c: Adjust with int128 effective target.
* gcc.target/powerpc/pr109932-2.c: Ditto.

13 months agoada: Fix decoration of iterated component association for GNATprove
Piotr Trojanek [Wed, 3 May 2023 13:26:23 +0000 (15:26 +0200)]
ada: Fix decoration of iterated component association for GNATprove

This patch is an alternative solution for a recent fix in analysis of
iterated component association.

To recap, if the iterated expression is an aggregate, we want to
propagate the component type downward with a call to Resolve_Aggr_Expr;
otherwise we want this expression to be only preanalysed (since the
association might need to be repeatedly evaluated), but also we need to
apply predicate and range checks to the expression itself (these are
required for GNATprove).

It turns out that Resolve_Aggr_Expr already knows how to deal with a
nested aggregate and also works for GNATprove, where it both preanalyzes
the expression and applies necessary checks.

In other words, expression of the iterated component association is now
resolved just like expression of an ordinary array aggregate.

gcc/ada/

* sem_aggr.adb (Resolve_Iterated_Component_Association): Simply resolve
the expression.

13 months agoada: Add missing ss_mark/ss_release in quantified expressions
Bob Duff [Wed, 3 May 2023 12:42:24 +0000 (08:42 -0400)]
ada: Add missing ss_mark/ss_release in quantified expressions

If a quantified expression says "for all ... of F(...)"
where F(...) is a function call that returns on the secondary
stack, we need to clean up the secondary stack. This patch
adds the required ss_mark/ss_release in that case.

gcc/ada/

* exp_ch4.adb
(Expand_N_Quantified_Expression): Detect the secondary-stack
case, and find the innermost scope where we should mark/release,
and Set_Uses_Sec_Stack on that. Skip intermediate blocks and loops
that are part of expansion.

13 months agoada: Recognize iterated_component_association as repeatedly evaluated
Piotr Trojanek [Wed, 3 May 2023 11:52:44 +0000 (13:52 +0200)]
ada: Recognize iterated_component_association as repeatedly evaluated

As iterated_component_association is an array_component_association
(because of a grammar rule Ada 2022 RM 4.3.3(5/5)), its expression is
repeatedly evaluated (because of Ada 2022 RM 6.1.1(22.14/5)).

With this patch we will now get errors for both conjuncts in this code,
which have semantically equivalent array aggregates that use an ordinary
component association and iterated component association.

  procedure Iter (S : String)
    with Post => String'(for J in 1 .. 3 => S (S'First)'Old) =
                 String'(         1 .. 3 => S (S'First)'Old);

gcc/ada/

* sem_util.adb (Is_Repeatedly_Evaluated): Recognize iterated component
association as repeatedly evaluated.

13 months agoada: Recognize iterated_component_association as potentially unevaluated
Piotr Trojanek [Wed, 3 May 2023 09:39:52 +0000 (11:39 +0200)]
ada: Recognize iterated_component_association as potentially unevaluated

Routine Is_Potentially_Unevaluated was written for Ada 2012, but now we
use it for Ada 2022 as well, so it must recognize iterated component
associations (which were added by Ada 2022) as an array component
association.

gcc/ada/

* sem_util.adb (Is_Potentially_Unevaluated): Recognize iterated
component association as potentially unevaluated.

13 months agoada: Disable inlining in potentially unevaluated contexts
Piotr Trojanek [Wed, 3 May 2023 07:23:29 +0000 (09:23 +0200)]
ada: Disable inlining in potentially unevaluated contexts

Instead of explicitly disabling inlining in quantified expressions,
(which happen to be only preanalysed) and then disabling inlining in
potentially unevaluated contexts that are fully analysed (which happen
to include quantified expressions), we now simply disable inlining in
all potentially unevaluated contexts, regardless of the full analysis
mode.

This also disables inlining in iterated component associations, which
can be both preanalysed or fully analysed depending on their expression,
but nevertheless are potentially unevaluated.

gcc/ada/

* sem_res.adb (Resolve_Call): Replace early call to
In_Quantified_Expression with a call to Is_Potentially_Unevaluated that
was only done when Full_Analysis is true.

13 months agoada: Implement new aspect Always_Terminates for SPARK
Piotr Trojanek [Tue, 2 May 2023 14:03:18 +0000 (16:03 +0200)]
ada: Implement new aspect Always_Terminates for SPARK

This patch allows subprograms to be annotated with aspect
Always_Terminates that requires a boolean expression. When this
expression evaluates to True, the subprogram is required to terminate or
raise an exception, but not loop infinitely.

This aspect is only meant to be used by GNATprove and it has no
meaningful run-time semantics: either the annotated subprogram
terminates and then the aspect expression doesn't matter, or the
subprogram loops infinitely and there is nothing we can do. (We could
also evaluate the aspect expression just to detect run-time errors in
the expression itself, but this can be implemented later, after a
backend support for the aspect is added to GNATprove.)

Implementation of this aspect is heavily based on the implementation of
Subprogram_Variant, which in turn is heavily based on the implementation
of Contract_Cases. Since the new aspect is not yet expanded, there is no
corresponding assertion kind that would control the expansion.

gcc/ada/

* aspects.ads (Aspect_Id): Add new aspect.
(Implementation_Defined_Aspect): New aspect is
implementation-defined.
(Aspect_Argument): New aspect has an expression argument.
(Is_Representation_Aspect): New aspect is not a representation
aspect.
(Aspect_Names): Link new aspect identifier with a name.
(Aspect_Delay): New aspect is never delayed.
* contracts.adb (Expand_Subprogram_Contract): Mention new aspect
in comment.
(Add_Contract_Item): Attach pragma corresponding to the new aspect
to contract items.
(Analyze_Entry_Or_Subprogram_Contract): Analyze pragma
corresponding to the new aspect that appears with subprogram spec.
(Analyze_Subprogram_Body_Stub_Contract): Expand pragma
corresponding to the new aspect.
* contracts.ads
(Add_Contract_Item, Analyze_Entry_Or_Subprogram_Contract)
(Analyze_Entry_Or_Subprogram_Body_Contract)
(Analyze_Subprogram_Body_Stub_Contract): Mention new aspect in
comment.
* einfo-utils.adb (Get_Pragma): Return pragma attached to
contract.
* einfo-utils.ads (Get_Pragma): Mention new contract in comment.
* exp_prag.adb (Expand_Pragma_Always_Terminates): Placeholder for
possibly expanding new aspect.
* exp_prag.ads (Expand_Pragma_Always_Terminates): Dedicated
routine for expansion of the new aspect.
* inline.adb (Remove_Aspects_And_Pragmas): Remove aspect from
inlined bodies.
* par-prag.adb (Prag): Postpone checking of the pragma until
analysis.
* sem_ch12.adb: Mention new aspect in explanation of handling
contracts on generic units.
* sem_ch13.adb (Analyze_Aspect_Specifications): Convert new aspect
into a corresponding pragma.
(Check_Aspect_At_Freeze_Point): Don't expect new aspect.
* sem_prag.adb (Analyze_Always_Terminates_In_Decl_Part): Analyze
pragma corresponding to the new aspect.
(Analyze_Pragma): Handle pragma corresponding to the new aspect.
(Is_Non_Significant_Pragma_Reference): Handle references appearing
within new aspect.
* sem_prag.ads (Aspect_Specifying_Pragma): New aspect can be
emulated with a pragma.
(Assertion_Expression_Pragma): New aspect has an assertion
expression.
(Pragma_Significant_To_Subprograms): New aspect is significant to
subprograms.
(Analyze_Always_Terminates_In_Decl_Part): Add spec for routine
that analyses new aspect.
(Find_Related_Declaration_Or_Body): Mention new aspect in comment.
* sem_util.adb (Is_Subprogram_Contract_Annotation): New aspect is
a subprogram contract annotation.
* sem_util.ads (Is_Subprogram_Contract_Annotation): Mention new
aspect in comment.
* sinfo.ads (Is_Generic_Contract_Pragma): New pragma is a generic
contract.
(Contract): Explain attaching new pragma to subprogram contract.
* snames.ads-tmpl (Name_Always_Terminates): New name for the new
contract.
(Pragma_Always_Terminates): New pragma identifier.

13 months agoada: Skip elaboration checks for abstract subprograms on derived types
Piotr Trojanek [Tue, 2 May 2023 10:49:43 +0000 (12:49 +0200)]
ada: Skip elaboration checks for abstract subprograms on derived types

Elaboration checks skip abstract subprogram declarations, which have no
body that could be examined. Now these checks also skip abstract
subprograms of a derived type, which have no body either.

gcc/ada/

* sem_elab.adb (Check_Overriding_Primitive): Prevent Corresponding_Body
to be called with entity of an abstract subprogram.

13 months agoada: Fix another case of missing Has_Private_View flag
Eric Botcazou [Fri, 28 Apr 2023 13:55:38 +0000 (15:55 +0200)]
ada: Fix another case of missing Has_Private_View flag

It occurs for the case of a function call first parsed as an identifier.

gcc/ada/

* sem_ch12.adb (Save_References_In_Identifier): In the case where
the identifier has been turned into a function call by analysis,
call Set_Global_Type on the entity if it is global.

13 months agoada: Fix iterated component initialization
Marc Poulhiès [Tue, 11 Apr 2023 07:46:33 +0000 (09:46 +0200)]
ada: Fix iterated component initialization

The call to Resolve_Aggr_Expr may leave references to temporary entities
used to check for the construct legality and meant to be removed.

Using Preanalyze_And_Resolve correctly guarantees that there is no
visible occurrence of such entities.

gcc/ada/

* sem_aggr.adb (Resolve_Iterated_Component_Association): Call
Preanalyze_And_Resolve instead of Resolve_Aggr_Expr except for
aggregate.

Co-authored-by: Ed Schonberg <schonberg@adacore.com>
13 months agoada: Fix exception raised on invalid contract in generic package
Eric Botcazou [Mon, 24 Apr 2023 09:07:38 +0000 (11:07 +0200)]
ada: Fix exception raised on invalid contract in generic package

This lets the compiler give a proper error message instead.

gcc/ada/

* contracts.adb (Contract_Error): New exception.
(Add_Contract_Item): Raise Contract_Error instead of Program_Error.
(Add_Generic_Contract_Pragma): Deal with Contract_Error.

13 months agoada: Fix spurious error on call to function returning private in generic
Eric Botcazou [Tue, 25 Apr 2023 21:20:08 +0000 (23:20 +0200)]
ada: Fix spurious error on call to function returning private in generic

The spurious error is given on a call to a parameterless function returning
a private type, present in the body of a generic construct both declared and
instantiated in the presence of the full view of the type, because this full
view is not properly restored for the instantiation.

This is supposed to be handled by the Has_Private_View mechanism, but it is
bypassed here because the call to the parameterless function is first parsed
as a simple identifier before being later analyzed as a function call.

Fixing this first issue uncovered another one, whereby the Has_Private_View
flag was not properly set on an operator returning a private type that ends
up being later resolved as a function call.

Finally a small loophole in Eval_Attribute exposed by the change also needs
to be plugged.

gcc/ada/

* sem_attr.adb (Eval_Attribute): Add more exceptions to the early
return for a prefix which is a nonfrozen generic actual type.
* sem_ch12.adb (Copy_Generic_Node): Also check private views in the
case of an entity name or operator analyzed as a function call.
(Set_Global_Type): Make it a child of Save_Global_References.
(Save_References_In_Operator): In the case where the operator has
been turned into a function call, call Set_Global_Type on the entity
if it is global.

13 months agoada: Fix internal error on imported function with post-condition
Eric Botcazou [Mon, 24 Apr 2023 15:11:01 +0000 (17:11 +0200)]
ada: Fix internal error on imported function with post-condition

The problem, which is also present for an expression function, is that the
function is invoked in the initializing expression of a variable declared
in the same declarative part as the function, which causes the freezing of
its artificial body before the post-condition is analyzed on its spec.

gcc/ada/

* contracts.adb (Analyze_Entry_Or_Subprogram_Body_Contract): For a
subprogram body that has no contracts and does not come from source,
make sure that contracts on its corresponding spec are analyzed, if
any, before expanding them.

13 months agoada: Streamline expansion of controlled actions for aggregates
Eric Botcazou [Mon, 24 Apr 2023 18:50:39 +0000 (20:50 +0200)]
ada: Streamline expansion of controlled actions for aggregates

This changes the strategy used to expand controlled actions for array and
record aggregates so as to make it simpler and more robust.

The current strategy is to set the No_Ctrl_Actions flag on the assignments
generated during the expansion of aggregate, as done during the expansion
of initialization procedures, and to generate the adjustments of the LHS
manually in the same list of actions, before sending the entire list for
analysis and expansion.  The problem is that, when the RHS also requires
controlled actions, the No_Ctrl_Actions flag prevents transient scopes
from being created around the assignments, with the end result that the
actions are "naturally" generated between the assignments and adjustments
of the LHS, causing premature finalization of the RHS.  In order to counter
that, the controlled actions of the RHS must also be generated manually
during the expansion of the aggregates, after blocking normal processing
e.g. by means of the No_Side_Effect_Removal flag.  This means that, for
a more complex RHS, this strategy generates a wrong order of controlled
actions by default, until specifically adjusted.

The new strategy is to reuse the standard machinery as much as possible,
disabling only the part that is not needed for the assignments generated
during the expansion of aggregates, namely the finalization of the LHS;
in other words, the adjustment of the LHS is left entirely to the standard
machinery and the creation of transient scopes is no longer blocked, which
gives a correct order of controlled actions by default.  It is implemented
by means of a No_Finalize_Actions flag present on the assignments generated
during the expansion.

It is mostly straightforward, modulo the following hitch: the assignments
are now analyzed and expanded by the common expander, which in the case of
controlled assignments analyzes the final rewriting with all checks off,
which in particular disables elaboration checks for the calls to the Adjust
primitives; now these checks are necessary in the case where an aggregate
is the initialization expression of an object declared before the body of
the Adjust primitive is seen.  Hence the use of an existing trick, namely
Suppress/Unsuppress blocks, around the assignments.

gcc/ada/

* gen_il-fields.ads (Opt_Field_Enum): Add No_Finalize_Actions and
remove No_Side_Effect_Removal.
* gen_il-gen-gen_nodes.adb (N_Function_Call): Remove semantic flag
No_Side_Effect_Removal
(N_Assignment_Statement): Add semantic flag No_Finalize_Actions.
* sinfo.ads (No_Ctrl_Actions): Adjust comment.
(No_Finalize_Actions): New flag on assignment statements.
(No_Side_Effect_Removal): Delete.
* exp_aggr.adb (Build_Record_Aggr_Code): Remove obsolete comment and
Ancestor_Is_Expression variable.  In the case of an extension, do
not generate a call to Adjust manually, call Set_No_Finalize_Actions
instead.  Do not set the tags, replace call to Make_Unsuppress_Block
by Make_Suppress_Block and remove useless assertions.
In the general case, call Initialize_Component.
(Initialize_Controlled_Component): Delete.
(Initialize_Simple_Component): Delete.
(Initialize_Component): Do the low-level processing, but do not
generate a call to Adjust manually, call Set_No_Finalize_Actions.
(Process_Transient_Component): Delete.
(Process_Transient_Component_Completion): Likewise.
* exp_ch5.adb (Expand_Assign_Array): Deal with No_Finalize_Actions.
(Expand_Assign_Array_Loop): Likewise.
(Expand_N_Assignment_Statement): Likewise.
(Make_Tag_Ctrl_Assignment): Likewise.
* exp_util.adb (Remove_Side_Effects): Do not test the
No_Side_Effect_Removal flag.
* sem_prag.adb (Process_Suppress_Unsuppress): Give the warning in
SPARK mode only for pragma Suppress.
* tbuild.ads (Make_Suppress_Block): New declaration.
(Make_Unsuppress_Block): Adjust comment.
* tbuild.adb (Make_Suppress_Block): New procedure.
(Make_Unsuppress_Block): Unsuppress instead of suppressing.

13 months agoada: Remove obsolete code in Analyze_Assignment
Eric Botcazou [Thu, 20 Apr 2023 15:20:46 +0000 (17:20 +0200)]
ada: Remove obsolete code in Analyze_Assignment

This code was dealing with build-in-place calls for nonlimited types, but
they no longer exist since Is_Build_In_Place_Result_Type => Is_Limited_View.

gcc/ada/

* sem_ch5.adb (Analyze_Assignment): Turn Rhs into a constant and
remove calls to the following subprograms.
(Transform_BIP_Assignment): Delete.
(Should_Transform_BIP_Assignment): Likewise.

13 months agoada: Remove unreferenced routine Is_Inherited_Operation_For_Type
Piotr Trojanek [Thu, 13 Apr 2023 12:53:52 +0000 (14:53 +0200)]
ada: Remove unreferenced routine Is_Inherited_Operation_For_Type

Remove routine that is no referenced after deconstructing of restriction
SPARK_05.

gcc/ada/

* sem_util.ads (Is_Inherited_Operation_For_Type): Remove spec.
* sem_util.adb (Is_Inherited_Operation_For_Type): Remove body.

13 months agoada: Small housekeeping work in expansion of extension aggregates
Eric Botcazou [Fri, 21 Apr 2023 16:37:12 +0000 (18:37 +0200)]
ada: Small housekeeping work in expansion of extension aggregates

This avoids repeatedly calling Unqualify on the same node, removes a dead
call to Generate_Finalization_Actions, a redundant setting of Assignment_OK
and reuses a local variable more consistently.  No functional changes.

gcc/ada/

* exp_aggr.adb (Build_Record_Aggr_Code): Add new variable Ancestor_Q
to store the result of Unqualify on Ancestor.  Remove the dead call
to Generate_Finalization_Actions in the case of another aggregate as
ancestor part.  Remove the redundant setting of Assignment_OK.  Use
Init_Typ in lieu of Etype (Ancestor) more consistently.

13 months agoada: Fix wrong expansion of limited extension aggregate
Eric Botcazou [Fri, 21 Apr 2023 16:30:48 +0000 (18:30 +0200)]
ada: Fix wrong expansion of limited extension aggregate

This happens when the ancestor part is itself an aggregate: in this case,
the tag of the extension aggregate is wrongly set to that of the ancestor.

gcc/ada/

* exp_aggr.adb (Build_Record_Aggr_Code): In the case of an extension
aggregate of a limited type whose ancestor part is an aggregate, do
not skip the final code assigning the tag of the extension.

13 months agoada: Mark attribute Initialized as ghost code
Yannick Moy [Tue, 11 Apr 2023 09:24:32 +0000 (11:24 +0200)]
ada: Mark attribute Initialized as ghost code

Implement the SPARK RM change that defines attribute Initialized
as being ghost, i.e. only allowed where a ghost entity would be allowed.

gcc/ada/

* ghost.adb (Check_Ghost_Context): Allow absence of Ghost_Id
for attribute. Update error message to mention Ghost_Predicate.
(Is_Ghost_Attribute_Reference): New query.
* ghost.ads (Is_Ghost_Attribute_Reference): New query.
* sem_attr.adb (Resolve_Attribute): Check ghost context for ghost
attributes.

13 months agoada: Add No_Elaboration_Code_All pragma to System.Storage_Elements
Daniel King [Tue, 18 Apr 2023 08:18:36 +0000 (09:18 +0100)]
ada: Add No_Elaboration_Code_All pragma to System.Storage_Elements

Allows System.Storage_Elements to be used in units that
have the No_Elaboration_Code_All restriction.

gcc/ada/

* libgnat/s-stoele.ads: Add No_Elaboration_Code_All pragma.

13 months agoada: Factor out tag assignments from type in expander
Eric Botcazou [Wed, 19 Apr 2023 20:39:38 +0000 (22:39 +0200)]
ada: Factor out tag assignments from type in expander

They are performed in a few different places during expansion.

gcc/ada/

* exp_util.ads (Make_Tag_Assignment_From_Type): Declare.
* exp_util.adb (Make_Tag_Assignment_From_Type): New function.
* exp_aggr.adb (Build_Record_Aggr_Code): Call the above function.
(Initialize_Simple_Component): Likewise.
* exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Likewise.
(Build_Record_Init_Proc.Build_Init_Procedure ): Likewise.
(Make_Tag_Assignment): Likewise.  Rename local variable and call
Unqualify to go through qualified expressions.
* exp_ch4.adb (Expand_Allocator_Expression): Likewise.

13 months agoada: Use ghost predicate in standard library
Yannick Moy [Thu, 20 Apr 2023 10:15:16 +0000 (12:15 +0200)]
ada: Use ghost predicate in standard library

In preparation for attribute Initialized to become ghost, use aspect
Ghost_Predicate instead of Predicate in unit Ada.Strings.Superbounded
of the standard library.

gcc/ada/

* libgnat/a-strsup.ads: Change predicate aspect.
* sem_ch13.adb (Add_Predicate): Fix for first predicate.

13 months agoada: Fix expansion of aggregates with controlled components
Eric Botcazou [Wed, 19 Apr 2023 07:56:42 +0000 (09:56 +0200)]
ada: Fix expansion of aggregates with controlled components

The expansion is incorrect in the case where the initialization expression
of a component is a conditional expression that has a function call as one
of its dependent expressions, leading to a wrong order of initialization,
adjustment and finalization.

gcc/ada/

* exp_aggr.adb (Initialize_Component): Perform immediate expansion
of the initialization expression if it is a conditional expression
and the component type is controlled.

13 months agoada: Factor common processing in expansion of aggregates
Eric Botcazou [Tue, 18 Apr 2023 10:44:55 +0000 (12:44 +0200)]
ada: Factor common processing in expansion of aggregates

The final processing at the component level of array aggregates and record
aggregates is very similar, so this factors out the common processing into
three new library-level subprograms.

There should be no functional changes, but the expanded code may be changed
in the case of controlled components of array aggregates not covered by a
multiple choice: the previous expansion used to place new declarations prior
to the aggregate in this case and that is no longer the case, i.e. they are
always placed right before the initialization of the component (as was done
for all controlled components of record aggregates and controlled components
of array aggregates covered by a multiple choice).

gcc/ada/

* exp_aggr.adb (Initialize_Component): New procedure factored out
from the processing of array and record aggregates.
(Initialize_Controlled_Component): Likewise.
(Initialize_Simple_Component): Likewise.
(Build_Array_Aggr_Code.Gen_Assign): Remove In_Loop parameter.
Call Initialize_Component to initialize the component.
(Initialize_Array_Component): Delete.
(Initialize_Ctrl_Array_Component): Likewise.
(Build_Array_Aggr_Code): Adjust calls to Gen_Assign.
(Build_Record_Aggr_Code): Call Initialize_Simple_Component or
Initialize_Component to initialize the component.
(Initialize_Ctrl_Record_Component): Delete.
(Initialize_Record_Component): Likewise.

13 months agoada: Remove wrong comment about expansion of exceptions for GNATprove
Piotr Trojanek [Wed, 19 Apr 2023 09:37:59 +0000 (11:37 +0200)]
ada: Remove wrong comment about expansion of exceptions for GNATprove

Code cleanup related to handling exceptions in GNATprove.

gcc/ada/

* exp_ch11.adb (Expand_N_Raise_Statement): Expansion of raise statements
never happens in GNATprove mode.

13 months agoada: Cleanup finding of locally handled exception handlers
Piotr Trojanek [Wed, 19 Apr 2023 09:02:34 +0000 (11:02 +0200)]
ada: Cleanup finding of locally handled exception handlers

Code cleanup related to handling exceptions in GNATprove; semantics is
unaffected.

gcc/ada/

* exp_ch11.adb (Find_Local_Handler): Replace guard against other
constructs appearing in the list of exception handlers with iteration
using First_Non_Pragma/Next_Non_Pragma.

13 months agoada: Cleanup expansion of locally handled exception handlers
Piotr Trojanek [Tue, 18 Apr 2023 17:13:38 +0000 (19:13 +0200)]
ada: Cleanup expansion of locally handled exception handlers

Code cleanup related to handling exceptions in GNATprove; semantics is
unaffected.

gcc/ada/

* exp_ch11.ads (Find_Local_Handler): Fix typo in comment.
* exp_ch11.adb (Find_Local_Handler): Remove redundant check for the
Exception_Handler list being present; use membership test to eliminate
local object LCN; fold nested IF statements. Remove useless ELSIF
condition.

13 months agoada: Tune style in detection of writable function actuals
Piotr Trojanek [Mon, 20 Mar 2023 19:27:09 +0000 (20:27 +0100)]
ada: Tune style in detection of writable function actuals

Cleanup; semantics is unaffected.

gcc/ada/

* sem_util.adb (Check_Function_Writable_Actuals): Tune style; use
subtype name to detect membership test nodes.

13 months agoada: Simplify appending to a newly created list
Piotr Trojanek [Fri, 14 Apr 2023 11:11:03 +0000 (13:11 +0200)]
ada: Simplify appending to a newly created list

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_disp.adb (Make_Disp_Asynchronous_Select_Spec): Use a single call
to New_List.

13 months agoada: Support new GNAT-specific aspect Ghost_Predicate
Yannick Moy [Fri, 14 Apr 2023 15:20:25 +0000 (17:20 +0200)]
ada: Support new GNAT-specific aspect Ghost_Predicate

New aspect Ghost_Predicate allows the use of ghost entities in the
predicate expression, even if the type is not ghost itself. As a result,
subtypes with a ghost predicate cannot be used in membership tests.

Subtypes with ghost predicates are subject to the same additional
restrictions as subtypes with aspect Dynamic_Predicate.
They are governed for compilation by assertion policy Ghost.
Checking of the predicate itself is governed by the usual assertion
policy (Static_Predicate/Dynamic_Predicate/Predicate) independently
of the ghost predicate.

gcc/ada/

* doc/gnat_rm/implementation_defined_aspects.rst: Document new
aspect.
* doc/gnat_rm/implementation_defined_pragmas.rst: Whitespace.
* aspects.adb (Init_Canonical_Aspect): Set it to Predicate.
* aspects.ads: Set global constants for new aspect.
* einfo.ads: Describe new flag related to new aspect.
* exp_ch6.adb (Can_Fold_Predicate_Call): Do not fold new aspect.
* exp_util.adb (Make_Predicate_Check): Add comment.
* gen_il-fields.ads: Add new flag.
* gen_il-gen-gen_entities.adb: Add new flag.
* ghost.adb (Is_OK_Ghost_Context): Ghost predicate is an OK
ghost context.
(Mark_Ghost_Pragma): Add overloading with ghost mode parameter.
* ghost.ads (Mark_Ghost_Pragma): Add overloading with ghpst mode
parameter.
(Name_To_Ghost_Mode): Make function public.
* sem_aggr.adb: Issue error for violation of valid use.
* sem_case.adb: Issue error for violation of valid use.
* sem_ch13.adb: Adapt for new aspect.
* sem_ch3.adb (Analyze_Full_Type_Declaration): Remove dead code
which was trying to propagate Has_Predicates flag in the wrong
direction (from derived to parent type).
(Analyze_Number_Declaration): Issue error for violation of valid
use.
(Build_Derived_Type): Cleanup inheritance of predicate flags from
parent to derived type.
(Build_Predicate_Function): Only add a predicate check when it
is not ignored as Ghost code.
* sem_ch4.adb (Analyze_Membership_Op): Issue an error for use of
a subtype with a ghost predicate as name in a membership test.
* sem_ch5.adb (Check_Predicate_Use): Issue error for violation of
valid use.
* sem_eval.adb: Adapt code for Dynamic_Predicate to account for
Ghost_Predicate too.
* sem_prag.adb (Analyze_Pragma): Make pragma ghost or not.
* sem_util.adb (Bad_Predicated_Subtype_Use): Adapt to new aspect.
(Inherit_Predicate_Flags): Add inheritance of flag. Add parameter
to apply to derived types.
* sem_util.ads (Inherit_Predicate_Flags): Change signature.
* snames.ads-tmpl: Add new aspect name.
* gnat_rm.texi: Regenerate.

13 months agoada: Remove explicit decoration of wrapper created in freezing
Piotr Trojanek [Mon, 17 Apr 2023 10:14:28 +0000 (12:14 +0200)]
ada: Remove explicit decoration of wrapper created in freezing

We create wrapper functions associated with inherited functions with
controlling results which are not overridden during freezing. We partly
decorated them explicitly, even though they would be fully decorated
later anyway.

This early decoration didn't work as expected, because flag
In_Private_Part that is read by Override_Dispatching_Operation it not
set reliably while freezing (as explained in the comment of
Is_Private_Declaration). In effect, we were getting a circularity
between Alias and Overridden_Operation, which was causing GNATprove to
loop infinitely.

Apparently the cleanest fix is to not decorate the wrapper with an early
call to Override_Dispatching_Operation.

gcc/ada/

* exp_ch3.adb (Make_Controlling_Function_Wrappers): Remove early
decoration.

13 months agoRISC-V: Fix one typo in full-vec-movel test
Pan Li [Tue, 13 Jun 2023 07:13:48 +0000 (15:13 +0800)]
RISC-V: Fix one typo in full-vec-movel test

This patch would like to fix one typo when checking assembly of
full-vec-movel.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls-vlmax/full-vec-move1.c:
Adjust dg-do to comiple for asm checking.

13 months agoAArch64: [PR96339] Optimise svlast[ab]
Tejas Belagod [Tue, 11 May 2021 10:09:03 +0000 (11:09 +0100)]
AArch64: [PR96339] Optimise svlast[ab]

  This PR optimizes an SVE intrinsics sequence where
    svlasta (svptrue_pat_b8 (SV_VL1), x)
  a scalar is selected based on a constant predicate and a variable vector.
  This sequence is optimized to return the correspoding element of a NEON
  vector. For eg.
    svlasta (svptrue_pat_b8 (SV_VL1), x)
  returns
    umov    w0, v0.b[1]
  Likewise,
    svlastb (svptrue_pat_b8 (SV_VL1), x)
  returns
     umov    w0, v0.b[0]
  This optimization only works provided the constant predicate maps to a range
  that is within the bounds of a 128-bit NEON register.

gcc/ChangeLog:

PR target/96339
* config/aarch64/aarch64-sve-builtins-base.cc (svlast_impl::fold): Fold sve
calls that have a constant input predicate vector.
(svlast_impl::is_lasta): Query to check if intrinsic is svlasta.
(svlast_impl::is_lastb): Query to check if intrinsic is svlastb.
(svlast_impl::vect_all_same): Check if all vector elements are equal.

gcc/testsuite/ChangeLog:

PR target/96339
* gcc.target/aarch64/sve/acle/general-c/svlast.c: New.
* gcc.target/aarch64/sve/acle/general-c/svlast128_run.c: New.
* gcc.target/aarch64/sve/acle/general-c/svlast256_run.c: New.
* gcc.target/aarch64/sve/pcs/return_4.c (caller_bf16): Fix asm
to expect optimized code for function body.
* gcc.target/aarch64/sve/pcs/return_4_128.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_4_256.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_4_512.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_4_1024.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_4_2048.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_5.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_5_128.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_5_256.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_5_512.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_5_1024.c (caller_bf16): Likewise.
* gcc.target/aarch64/sve/pcs/return_5_2048.c (caller_bf16): Likewise.

13 months agoUpdate perf auto profile script
Andi Kleen [Tue, 30 May 2023 11:05:39 +0000 (04:05 -0700)]
Update perf auto profile script

- Fix gen_autofdo_event: The download URL for the Intel Perfmon Event
  list has changed, as well as the JSON format.
  Also it now uses pattern matching to match CPUs. Update the script to support all of this.
- Regenerate gcc-auto-profile with the latest published Intel model
  numbers, so it works with recent systems.
- So far it's still broken on hybrid systems

contrib/ChangeLog:

* gen_autofdo_event.py: Update for download server changes

gcc/ChangeLog

* config/i386/gcc-auto-profile: Regenerate.

13 months agoRISC-V: Fix V_WHOLE && V_FRACT iterator requirement
Juzhe-Zhong [Fri, 9 Jun 2023 14:32:41 +0000 (22:32 +0800)]
RISC-V: Fix V_WHOLE && V_FRACT iterator requirement

This patch fixes the requirement of V_WHOLE and V_FRACT.
E.g. VNx8QI in V_WHOLE has no requirement which is incorrect.
     Actually, VNx8QI should be whole(full) mode when TARGET_MIN_VLEN < 128
     since when TARGET_MIN_VLEN == 128, VNx8QI is e8mf2 which is fractional
     vector.

Co-Authored by: Robin Dapp <rdapp@ventanamicro.com>

gcc/ChangeLog:

* config/riscv/vector-iterators.md: Fix requirement.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls-vlmax/full-vec-move1.c: New test.

13 months agoRISC-V: Enhance RVV VLA SLP auto-vectorization with decompress operation
Juzhe-Zhong [Mon, 12 Jun 2023 15:11:07 +0000 (23:11 +0800)]
RISC-V: Enhance RVV VLA SLP auto-vectorization with decompress operation

According to RVV ISA:
https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc

We can enhance VLA SLP auto-vectorization with (16.5.1. Synthesizing vdecompress)
Decompress operation.

Case 1 (nunits = POLY_INT_CST [16, 16]):
_48 = VEC_PERM_EXPR <_37, _35, { 0, POLY_INT_CST [16, 16], 1, POLY_INT_CST [17, 16], 2, POLY_INT_CST [18, 16], ... }>;
We can optimize such VLA SLP permuation pattern into:
_48 = vdecompress (_37, _35, mask = { 0, 1, 0, 1, ... };

Case 2 (nunits = POLY_INT_CST [16, 16]):
_23 = VEC_PERM_EXPR <_46, _44, { POLY_INT_CST [1, 1], POLY_INT_CST [3, 3], POLY_INT_CST [2, 1], POLY_INT_CST [4, 3], POLY_INT_CST [3, 1], POLY_INT_CST [5, 3], ... }>;
We can optimize such VLA SLP permuation pattern into:
_48 = vdecompress (slidedown(_46, 1/2 nunits), slidedown(_44, 1/2 nunits), mask = { 0, 1, 0, 1, ... };

For example:
void __attribute__ ((noinline, noclone))
vec_slp (uint64_t *restrict a, uint64_t b, uint64_t c, int n)
{
  for (int i = 0; i < n; ++i)
    {
      a[i * 2] += b;
      a[i * 2 + 1] += c;
    }
}

ASM:
...
        vid.v   v0
        vand.vi v0,v0,1
        vmseq.vi        v0,v0,1  ===> mask = { 0, 1, 0, 1, ... }
vdecompress:
        viota.m v3,v0
        vrgather.vv     v2,v1,v3,v0.t
Loop:
        vsetvli zero,a5,e64,m1,ta,ma
        vle64.v v1,0(a0)
        vsetvli a6,zero,e64,m1,ta,ma
        vadd.vv v1,v2,v1
        vsetvli zero,a5,e64,m1,ta,ma
        mv      a5,a3
        vse64.v v1,0(a0)
        add     a3,a3,a1
        add     a0,a0,a2
        bgtu    a5,a4,.L4

gcc/ChangeLog:

* config/riscv/riscv-v.cc (emit_vlmax_decompress_insn): New function.
(shuffle_decompress_patterns): New function.
(expand_vec_perm_const_1): Add decompress optimization.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/slp-8.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp-9.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp_run-8.c: New test.
* gcc.target/riscv/rvv/autovec/partial/slp_run-9.c: New test.

13 months agoDaily bump.
GCC Administrator [Tue, 13 Jun 2023 00:17:29 +0000 (00:17 +0000)]
Daily bump.

13 months agoPR modula2/110189 Using an unknown TYPE as argument to VAL gives ICE
Gaius Mulley [Mon, 12 Jun 2023 23:53:53 +0000 (00:53 +0100)]
PR modula2/110189 Using an unknown TYPE as argument to VAL gives ICE

This patch tidies P3Build.bnf and fixes error format specs in
M2Quads.mod when encountering unknown symbols.

gcc/m2/ChangeLog:

PR modula2/110189
* gm2-compiler/M2Quads.mod (BuildAbsFunction): Replace abort
format specifier.
(BuildValFunction): Replace abort format specifier.
(BuildCastFunction): Replace abort format specifier.
(BuildMinFunction): Replace abort format specifier.
(BuildMaxFunction): Replace abort format specifier.
(BuildTruncFunction): Replace abort format specifier.
* gm2-compiler/P3Build.bnf (Pass1): Remove.
(Pass2): Remove.
(Pass3): Remove.
(Expect): Add Pass1.
(AsmStatement): Remove Pass3.
(AsmOperands): Remove Pass3.
(AsmOperandSpec): Remove Pass3.
(AsmInputElement): Remove Pass3.
(AsmOutputElement): Remove Pass3.
(AsmTrashList): Remove Pass3.

gcc/testsuite/ChangeLog:

PR modula2/110189
* gm2/pim/fail/foovaltype.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
13 months ago[committed] [PR rtl-optimization/101188] Fix reload_cse_move2add ignoring clobbers
Jeff Law [Mon, 12 Jun 2023 18:52:10 +0000 (12:52 -0600)]
[committed] [PR rtl-optimization/101188] Fix reload_cse_move2add ignoring clobbers

So as Georg-Johann discusses in the BZ, reload_cse_move2add can generate
 incorrect code when optimizing code with clobbers.  Specifically in the
case where we try to optimize a sequence of 4 operations down to 3
operations we can reset INSN to the next instruction and continue the loop.

That skips the code to invalidate objects based on things like REG_INC
nodes, stack pushes and most importantly clobbers attached to the current
insn.

This patch factors all of the invalidation code used by reload_cse_move2add
into a new function and calls it at the appropriate time.

Georg-Johann has confirmed this patch fixes his avr bug and I've had it in
my tester over the weekend.  It's bootstrapped and regression tested on
aarch64, m68k, sh4, alpha and hppa.  It's also regression tested successfully
on a wide variety of other targets.

gcc/
PR rtl-optimization/101188
* postreload.cc (reload_cse_move2add_invalidate): New function,
extracted from...
(reload_cse_move2add): Call reload_cse_move2add_invalidate.

gcc/testsuite
PR rtl-optimization/101188
* gcc.c-torture/execute/pr101188.c: New test

13 months ago[aarch64] Improve code-gen for vector initialization with single constant element.
Prathamesh Kulkarni [Mon, 12 Jun 2023 17:44:40 +0000 (23:14 +0530)]
[aarch64] Improve code-gen for vector initialization with single constant element.

gcc/ChangeLog:
* config/aarch64/aarch64.cc (aarch64_expand_vector_init): Tweak condition
if (n_var == n_elts && n_elts <= 16) to allow a single constant,
and if maxv == 1, use constant element for duplicating into register.

gcc/testsuite/ChangeLog:
* gcc.target/aarch64/vec-init-single-const.c: New test.
* gcc.target/aarch64/vec-init-single-const-be.c: Likewise.
* gcc.target/aarch64/vec-init-single-const-2.c: Likewise.

13 months agoOpenMP: Cleanups related to the 'present' modifier
Tobias Burnus [Mon, 12 Jun 2023 16:15:28 +0000 (18:15 +0200)]
OpenMP: Cleanups related to the 'present' modifier

Reduce number of enum values passed to libgomp as
GOMP_MAP_PRESENT_{TO,TOFROM,FROM,ALLOC} have the same semantic as
GOMP_MAP_FORCE_PRESENT (i.e. abort if not present, otherwise ignore);
that's different to GOMP_MAP_ALWAYS_PRESENT_{TO,TOFROM,FROM} which also
abort if not present but copy data when present. This is is a follow-up to
the commit r14-1579-g4ede915d5dde93 done 6 days ago.

Additionally, the commit improves a libgomp run-time and a C/C++ compile-time
error wording and extends testcases a tiny bit.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_clause_map): Reword error message for
clearness especially with 'omp target (enter/exit) data.'

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_clause_map): Reword error message for
clearness especially with 'omp target (enter/exit) data.'
* semantics.cc (handle_omp_array_sections): Handle
GOMP_MAP_{ALWAYS_,}PRESENT_{TO,TOFROM,FROM,ALLOC} enum values.

gcc/ChangeLog:

* gimplify.cc (gimplify_adjust_omp_clauses_1): Use
GOMP_MAP_FORCE_PRESENT for 'present alloc' implicit mapping.
(gimplify_adjust_omp_clauses): Change
GOMP_MAP_PRESENT_{TO,TOFROM,FROM,ALLOC} to the equivalent
GOMP_MAP_FORCE_PRESENT.
* omp-low.cc (lower_omp_target): Remove handling of no-longer valid
GOMP_MAP_PRESENT_{TO,TOFROM,FROM,ALLOC}; update map kinds used for
to/from clauses with present modifier.

include/ChangeLog:

* gomp-constants.h (enum gomp_map_kind): Change the enum values
GOMP_MAP_PRESENT_{TO,TOFROM,FROM,ALLOC} to be compiler only.
(GOMP_MAP_PRESENT_P): Update to include also GOMP_MAP_FORCE_PRESENT.

libgomp/ChangeLog:

* target.c (gomp_to_device_kind_p, gomp_map_vars_internal): Replace
GOMP_MAP_PRESENT_{FROM,TO,TOFROM,ACLLOC} by GOMP_MAP_FORCE_PRESENT.
(gomp_map_vars_internal, gomp_update): Likewise; unify and improve
error message.
* testsuite/libgomp.c-c++-common/target-present-2.c: Update for
changed error message.
* testsuite/libgomp.fortran/target-present-1.f90: Likewise.
* testsuite/libgomp.fortran/target-present-2.f90: Likewise.
* testsuite/libgomp.oacc-c-c++-common/present-1.c: Likewise.
* testsuite/libgomp.c-c++-common/target-present-1.c: Likewise and
extend testcase to check that data is copied when needed.
* testsuite/libgomp.c-c++-common/target-present-3.c: Likewise.
* testsuite/libgomp.fortran/target-present-3.f90: Likewise.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/defaultmap-4.c: Update scan-tree-dump.
* c-c++-common/gomp/map-9.c: Likewise.
* gfortran.dg/gomp/defaultmap-8.f90: Likewise.
* gfortran.dg/gomp/map-11.f90: Likewise.
* gfortran.dg/gomp/target-update-1.f90: Likewise.
* gfortran.dg/gomp/map-12.f90: Likewise; also check original dump.
* c-c++-common/gomp/map-6.c: Update dg-error and also check
clause error with 'target (enter/exit) data'.

This page took 0.121044 seconds and 5 git commands to generate.