Commit graph

205607 commits

Author SHA1 Message Date
Iain Buclaw
1250858ac9 d: Merge upstream dmd ff57fec515, druntime ff57fec515, phobos 17bafda79.
D front-end changes:

    - Import dmd v2.106.0-rc.1.
    - New'ing multi-dimensional arrays are now are converted to a single
      template call `_d_newarraymTX'.

D runtime changes:

    - Import druntime v2.106.0-rc.1.

Phobos changes:

    - Import phobos v2.106.0-rc.1.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd ff57fec515.
	* dmd/VERSION: Bump version to v2.106.0-rc.1.
	* expr.cc (ExprVisitor::visit (CatAssignExp *)): Update for new
	front-end interface.
	(ExprVisitor::visit (NewExp *)): Likewise.
	* runtime.def (NEWARRAYMTX): Remove.
	(NEWARRAYMITX): Remove.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime ff57fec515.
	* src/MERGE: Merge upstream phobos 17bafda79.

gcc/testsuite/ChangeLog:

	* gdc.dg/asm1.d: Adjust expected diagnostic.
2023-11-21 15:07:47 +01:00
Juzhe-Zhong
8faae311a6 RISC-V: Disallow COSNT_VECTOR for DI on RV32
This bug is exposed when testing on zvl512b RV32 system.

The rootcause is RA reload DI CONST_VECTOR into vmv.v.x then it ICE.

So disallow DI CONST_VECTOR on RV32.

	PR target/112598

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_const_insns): Disallow DI CONST_VECTOR on RV32.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr112598-1.c: New test.
2023-11-21 21:37:59 +08:00
Iain Buclaw
87b9a01ea7 d: Merge upstream dmd 65a3da148c, phobos fc06c514a.
D front-end changes:

    - Import latest bug fixes from dmd v2.106.0-beta.1.

Phobos changes:

    - Import latest bug fixes from phobos v2.106.0-beta.1.
    - `std.range.primitives.isForwardRange' now takes an optional
      element type.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 65a3da148c.

libphobos/ChangeLog:

	* src/MERGE: Merge upstream phobos fc06c514a.
2023-11-21 14:29:28 +01:00
Tamar Christina
da332ce109 AArch64: only emit mismatch error when features would be disabled.
At the moment we emit a warning whenever you specify both -march and -mcpu
and the architecture of them differ.  The idea originally was that the user may
not be aware of this change.

However this has a few problems:

1.  Architecture revisions is not an observable part of the architecture,
    extensions are.  Starting with GCC 14 we have therefore relaxed the rule that
    all extensions can be enabled at any architecture level.  Therefore it's
    incorrect, or at least not useful to keep the check on architecture.

2.  It's problematic in Makefiles and other build systems, where you want to
    for certain files enable CPU specific builds.  i.e. you may be by default
    building for -march=armv8-a but for some file for -mcpu=neoverse-n1.  Since
    there's no easy way to remove the earlier options we end up warning and
    there's no way to disable just this warning.  Build systems compiling with
    -Werror face an issue in this case that compiling with GCC is needlessly
    hard.

3. It doesn't actually warn for cases that may lead to issues, so e.g.
   -march=armv8.2-a+sve -mcpu=neoverse-n1 does not give a warning that SVE would
   be disabled.

For this reason I have one of two proposals:

1.  Just remove this warning all together.

2.  Rework the warning based on extensions and only warn when features would be
    disabled by the presence of the -mcpu.  This is the approach this patch has
    taken.

As examples:

> aarch64-none-linux-gnu-gcc -march=armv8.2-a+sve -mcpu=neoverse-n1
cc1: warning: switch ‘-mcpu=neoverse-n1’ conflicts with ‘-march=armv8.2-a+sve’ switch and resulted in options +crc+sve+norcpc+nodotprod being added                                                                                                                                        .arch armv8.2-a+crc+sve

> aarch64-none-linux-gnu-gcc -march=armv8.2-a -mcpu=neoverse-n1
> aarch64-none-linux-gnu-gcc -march=armv8.2-a+dotprod -mcpu=neoverse-n1
> aarch64-none-linux-gnu-gcc -march=armv8.2-a+dotprod -mcpu=neoverse-n2
<no warning>

The one remaining issue here is that if both -march and -mcpu are specified we
pick the -march.  This is not particularly obvious and for the use case to be
more useful I think it makes sense to pick the CPU's arch?

I did not make that change in the patch as it changes semantics.

Note that I can't write a test for this because dg-warning expects warnings to
be at a particular line and doesn't support warnings at the "global" level.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc (aarch64_override_options): Rework warnings.
2023-11-21 13:25:25 +00:00
Tamar Christina
c187fe4bce AArch64: Add new generic-armv9-a CPU and make it the default for Armv9
This patch adds a new generic scheduling model "generic-armv9-a" and makes it
the default for all Armv9 architectures.

-mcpu=generic and -mtune=generic is kept around for those that really want the
previous cost model.

gcc/ChangeLog:

	PR target/111370
	* config/aarch64/aarch64-arches.def (armv9-a, armv9.1-a, armv9.2-a,
	armv9.3-a): Update to generic-armv9-a.
	* config/aarch64/aarch64-cores.def (generic-armv9-a): New.
	* config/aarch64/aarch64-tune.md: Regenerate.
	* config/aarch64/aarch64.cc: Include generic_armv9_a.h.
	* config/aarch64/tuning_models/generic_armv9_a.h: New file.
2023-11-21 13:25:25 +00:00
Tamar Christina
33c2b70dba AArch64: Add new generic-armv8-a CPU and make it the default.
This patch adds a new generic scheduling model "generic-armv8-a" and makes it
the default for all Armv8 architectures.

-mcpu=generic and -mtune=generic is kept around for those that really want the
previous cost model.

This shows on SPECCPU 2017 the following:

generic:  SPECINT 1.0% improvement in geomean, SPECFP -0.6%.  The SPECFP is due
          to fotonik3d_r where we vectorize an FP calculation that only ever
	  needs one lane of the result.  This I believe is a generic costing bug
	  but at the moment we can't change costs of FP and INT independently.
	  So will defer updating that cost to stage3 after Richard's other
	  costing updates land.

generic SVE: SPECINT 1.1% improvement in geomean, SPECFP 0.7% improvement.

gcc/ChangeLog:

	PR target/111370
	* config/aarch64/aarch64-arches.def (armv8-9, armv8-a, armv8.1-a,
	armv8.2-a, armv8.3-a, armv8.4-a, armv8.5-a, armv8.6-a, armv8.7-a,
	armv8.8-a): Update to generic_armv8_a.
	* config/aarch64/aarch64-cores.def (generic-armv8-a): New.
	* config/aarch64/aarch64-tune.md: Regenerate.
	* config/aarch64/aarch64.cc: Include generic_armv8_a.h
	* config/aarch64/aarch64.h (TARGET_CPU_DEFAULT): Change to
	TARGET_CPU_generic_armv8_a.
	* config/aarch64/tuning_models/generic_armv8_a.h: New file.

gcc/testsuite/ChangeLog:

	PR target/111370
	* gcc.target/aarch64/sve/cond_asrd_1.c: Updated.
	* gcc.target/aarch64/sve/cond_cnot_4.c: Likewise.
	* gcc.target/aarch64/sve/cond_unary_5.c: Likewise.
	* gcc.target/aarch64/sve/cond_uxt_5.c: Likewise.
	* gcc.target/aarch64/target_attr_13.c: Likewise.
	* gcc.target/aarch64/target_attr_15.c: Likewise.
2023-11-21 13:25:10 +00:00
Tamar Christina
e5678468e5 AArch64: Remove special handling of generic cpu.
In anticipation of adding new generic turning values this removes the hardcoding
of the "generic" CPU and instead just specifies it as a normal CPU.

No change in behavior is expected.

gcc/ChangeLog:

	PR target/111370
	* config/aarch64/aarch64-cores.def: Add generic.
	* config/aarch64/aarch64-opts.h (enum aarch64_proc): Remove generic.
	* config/aarch64/aarch64-tune.md: Regenerate
	* config/aarch64/aarch64.cc (all_cores): Remove generic
	* config/aarch64/aarch64.h (enum target_cpus): Remove
	TARGET_CPU_generic.
2023-11-21 13:20:10 +00:00
Tamar Christina
4b6da8e7bd AArch64: Refactor costs models to different files.
This patch series attempts to move the generic cost model in AArch64 to a new
and modern generic standard.  The current standard is quite old and generates
very suboptimal code out of the box for user of GCC.

The goal is for the new cost model to be beneficial on newer/current Arm
Microarchitectures while not being too negative for older ones.

It does not change any core specific optimization.  The final changes reflect
both performance optimizations and size optimizations.

This first patch just re-organizes the cost structures to their own files.
The AArch64.cc file has gotten very big and it's hard to follow.

No functional changes are expected from this change.  Note that since all the
structures have private visibility I've put them in header files instead.

gcc/ChangeLog:

	PR target/111370
	* config/aarch64/aarch64.cc (generic_addrcost_table,
	exynosm1_addrcost_table,
	xgene1_addrcost_table,
	thunderx2t99_addrcost_table,
	thunderx3t110_addrcost_table,
	tsv110_addrcost_table,
	qdf24xx_addrcost_table,
	a64fx_addrcost_table,
	neoversev1_addrcost_table,
	neoversen2_addrcost_table,
	neoversev2_addrcost_table,
	generic_regmove_cost,
	cortexa57_regmove_cost,
	cortexa53_regmove_cost,
	exynosm1_regmove_cost,
	thunderx_regmove_cost,
	xgene1_regmove_cost,
	qdf24xx_regmove_cost,
	thunderx2t99_regmove_cost,
	thunderx3t110_regmove_cost,
	tsv110_regmove_cost,
	a64fx_regmove_cost,
	neoversen2_regmove_cost,
	neoversev1_regmove_cost,
	neoversev2_regmove_cost,
	generic_vector_cost,
	a64fx_vector_cost,
	qdf24xx_vector_cost,
	thunderx_vector_cost,
	tsv110_vector_cost,
	cortexa57_vector_cost,
	exynosm1_vector_cost,
	xgene1_vector_cost,
	thunderx2t99_vector_cost,
	thunderx3t110_vector_cost,
	ampere1_vector_cost,
	generic_branch_cost,
	generic_tunings,
	cortexa35_tunings,
	cortexa53_tunings,
	cortexa57_tunings,
	cortexa72_tunings,
	cortexa73_tunings,
	exynosm1_tunings,
	thunderxt88_tunings,
	thunderx_tunings,
	tsv110_tunings,
	xgene1_tunings,
	emag_tunings,
	qdf24xx_tunings,
	saphira_tunings,
	thunderx2t99_tunings,
	thunderx3t110_tunings,
	neoversen1_tunings,
	ampere1_tunings,
	ampere1a_tunings,
	neoversev1_vector_cost,
	neoversev1_tunings,
	neoverse512tvb_vector_cost,
	neoverse512tvb_tunings,
	neoversen2_vector_cost,
	neoversen2_tunings,
	neoversev2_vector_cost,
	neoversev2_tunings
	a64fx_tunings): Split into own files.
	* config/aarch64/tuning_models/a64fx.h: New file.
	* config/aarch64/tuning_models/ampere1.h: New file.
	* config/aarch64/tuning_models/ampere1a.h: New file.
	* config/aarch64/tuning_models/cortexa35.h: New file.
	* config/aarch64/tuning_models/cortexa53.h: New file.
	* config/aarch64/tuning_models/cortexa57.h: New file.
	* config/aarch64/tuning_models/cortexa72.h: New file.
	* config/aarch64/tuning_models/cortexa73.h: New file.
	* config/aarch64/tuning_models/emag.h: New file.
	* config/aarch64/tuning_models/exynosm1.h: New file.
	* config/aarch64/tuning_models/generic.h: New file.
	* config/aarch64/tuning_models/neoverse512tvb.h: New file.
	* config/aarch64/tuning_models/neoversen1.h: New file.
	* config/aarch64/tuning_models/neoversen2.h: New file.
	* config/aarch64/tuning_models/neoversev1.h: New file.
	* config/aarch64/tuning_models/neoversev2.h: New file.
	* config/aarch64/tuning_models/qdf24xx.h: New file.
	* config/aarch64/tuning_models/saphira.h: New file.
	* config/aarch64/tuning_models/thunderx.h: New file.
	* config/aarch64/tuning_models/thunderx2t99.h: New file.
	* config/aarch64/tuning_models/thunderx3t110.h: New file.
	* config/aarch64/tuning_models/thunderxt88.h: New file.
	* config/aarch64/tuning_models/tsv110.h: New file.
	* config/aarch64/tuning_models/xgene1.h: New file.
2023-11-21 13:19:36 +00:00
Tamar Christina
f26f92b534 AArch64: Add pattern for unsigned widenings (uxtl) to zip{1,2}
This changes unpack instructions to use zip{1,2} when doing a zero-extending
widening operation.  Permutes generally have a higher throughput than the
widening operations. Zeros are shuffled into the top half of the registers.

The testcase

void d2 (unsigned * restrict a, unsigned short *b, int n)
{
    for (int i = 0; i < (n & -8); i++)
      a[i] = b[i];
}

now generates:

        movi    v1.4s, 0
.L3:
        ldr     q0, [x1], 16
        zip1    v2.8h, v0.8h, v1.8h
        zip2    v0.8h, v0.8h, v1.8h
        stp     q2, q0, [x0]
        add     x0, x0, 32
        cmp     x1, x2
        bne     .L3

instead of:

.L3:
        ldr     q0, [x1], 16
        uxtl    v1.4s, v0.4h
        uxtl2   v0.4s, v0.8h
        stp     q1, q0, [x0]
        add     x0, x0, 32
        cmp     x1, x2
        bne     .L3

Since we need the extra 0 register we do this only for the vectorizer's lo/hi
pairs when we know the 0 will be floated outside of the loop.

This gives an 8% speed-up in Imagick in SPECCPU 2017 on Neoverse V2.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (vec_unpack<su>_lo_<mode,
	vec_unpack<su>_lo_<mode): Split into...
	(vec_unpacku_lo_<mode, vec_unpacks_lo_<mode,
	vec_unpacku_lo_<mode, vec_unpacks_lo_<mode): ...These.
	(aarch64_usubw<mode>_<PERM_EXTEND:perm_hilo>_zip): New.
	(aarch64_uaddw<mode>_<PERM_EXTEND:perm_hilo>_zip): New.
	* config/aarch64/iterators.md (PERM_EXTEND, perm_index): New.
	(perm_hilo): Add UNSPEC_ZIP1, UNSPEC_ZIP2.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/simd/vmovl_high_1.c: Update codegen.
	* gcc.target/aarch64/uxtl-combine-1.c: New test.
	* gcc.target/aarch64/uxtl-combine-2.c: New test.
	* gcc.target/aarch64/uxtl-combine-3.c: New test.
	* gcc.target/aarch64/uxtl-combine-4.c: New test.
	* gcc.target/aarch64/uxtl-combine-5.c: New test.
	* gcc.target/aarch64/uxtl-combine-6.c: New test.
2023-11-21 13:18:23 +00:00
Tamar Christina
5ff006bd3d AArch64: only discount MLA for vector and scalar statements
In testcases gcc.dg/tree-ssa/slsr-19.c  and gcc.dg/tree-ssa/slsr-20.c we have a
fairly simple computation.  On the current generic costing we generate:

f:
        add     w0, w0, 2
        madd    w1, w0, w1, w1
        lsl     w0, w1, 1
        ret

but on any other cost model but generic (including the new up coming generic)
we generate:

f:
        adrp    x2, .LC0
        dup     v31.2s, w0
        fmov    s30, w1
        ldr     d29, [x2, #:lo12:.LC0]
        add     v31.2s, v31.2s, v29.2s
        mul     v31.2s, v31.2s, v30.s[0]
        addp    v31.2s, v31.2s, v31.2s
        fmov    w0, s31
        ret
.LC0:
        .word   2
        .word   4

This seems to be because the vectorizer thinks the vector transfers are free:

x1_4 + x2_6 1 times vector_stmt costs 0 in body
x1_4 + x2_6 1 times vec_to_scalar costs 0 in body

This happens because the stmt it's using to get the cost of register transfers
for the given type happens to be one feeding into a MUL.  we incorrectly
discount the + for the register transfer.

This is fixed by guarding the check for aarch64_multiply_add_p with a kind
check and only do it for scalar_stmt and vector_stmt.

I'm sending this separate to my patch series but it's required for it.
It also seems to fix overvectorization cases in fotonik3d_r in SPECCPU 2017.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc (aarch64_adjust_stmt_cost): Guard mla.
	(aarch64_vector_costs::count_ops): Likewise.
2023-11-21 13:14:29 +00:00
Juzhe-Zhong
0a033038cd RISC-V: Add missing dump check of pr112438.c
Notice the dump check is missing, add it.

Committed as it is obvious.
gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr112438.c: Add missing dump check.
2023-11-21 20:57:59 +08:00
Thomas Schwinge
878a860cae Fix 'gcc.dg/tree-ssa/return-value-range-1.c'
... added in recent commit 53ba8d6695
"inter-procedural value range propagation".

	gcc/testsuite/
	* gcc.dg/tree-ssa/return-value-range-1.c: Fix.
2023-11-21 13:30:34 +01:00
Sebastian Huber
41aacdea55 gcov: Fix integer types in gen_counter_update()
This change fixes issues like this:

  gcc.dg/gomp/pr27573.c: In function ‘main._omp_fn.0’:
  gcc.dg/gomp/pr27573.c:19:1: error: non-trivial conversion in ‘ssa_name’
     19 | }
        | ^
  long int
  long unsigned int
  # .MEM_19 = VDEF <.MEM_18>
  __gcov7.main._omp_fn.0[0] = PROF_time_profile_12;
  during IPA pass: profile
  gcc.dg/gomp/pr27573.c:19:1: internal compiler error: verify_gimple failed

gcc/ChangeLog:

	PR middle-end/112634

	* tree-profile.cc (gen_assign_counter_update): Cast the unsigned result type of
	__atomic_add_fetch() to the signed counter type.
	(gen_counter_update): Fix formatting.
2023-11-21 11:42:50 +01:00
Eric Botcazou
4649c07940 ada: Fix miscompilation of loop over boolean range
The optimized form generated in this case turns out to be problematic.

gcc/ada/

	* gcc-interface/trans.cc (Loop_Statement_to_gnu): Always use the
	simpler form for a loop with a boolean iteration variable.
2023-11-21 10:57:43 +01:00
Eric Botcazou
4d011701c0 ada: Fix issue with indefinite vector of overaligned unconstrained array
The problem is that the aligning machinery is not consistently triggered,
depending on whether a constrained view or the nominal unconstrained view
of the element type is used to perform the allocations and deallocations.

gcc/ada/

	* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Subtype>: Put
	the alignment directly on the type in the constrained case too.
	* gcc-interface/utils.cc (maybe_pad_type): For an array type, take
	the alignment of the element type as the original alignment.
2023-11-21 10:57:43 +01:00
Gary Dismukes
1f61f81d6c ada: Compiler crash on container aggregate with loop_parameter_specifications
The compiler crashes on a container aggregate with more than one
iterated_element_association given by a loop_parameter_specification.
In such a case, the tree contains N_Iterated_Component_Association
nodes rather than N_Iterated_Element_Association nodes, and the code
for handling those needs to obtain the bounds from the Discrete_Choices
field of each N_Iterated_Component_Association rather than assuming
that the association has a normal list of choices.

gcc/ada/

	* sem_aggr.adb (Resolve_Container_Aggregate): In the case where Comp
	is an N_Iterated_Component_Association, pick up Discrete_Choices rather
	than Choices.
2023-11-21 10:57:43 +01:00
Eric Botcazou
5a6dbb34c5 ada: Another couple of cleanups in the finalization machinery
For package specs and bodies that need finalizers, Build_Finalizer is
invoked from the Standard scope so it needs to adjust the scope stack
before creating new objects; this changes it to do so only once.

For other kinds of scopes, it is invoked from Expand_Cleanup_Actions,
which assumes that the correct scope is already on the stack; that's
why Cleanup_Scopes adjusts the scope stack explicitly, but it should
use Pop_Scope instead of End_Scope to do it.

gcc/ada/

	* exp_ch7.adb (Build_Finalizer): For package specs and bodies, push
	and pop the specs onto the scope stack only once.
	* inline.adb (Cleanup_Scopes): Call Pop_Scope instead of End_Scope.
2023-11-21 10:57:43 +01:00
Steve Baird
87517ca34e ada: Deep delta aggregates in postconditions
Fix a bug in handling array-valued deep delta aggregates occurring in
postconditions. The bug could result in a spurious compilation failure.

gcc/ada/

	* sem_aggr.adb (Resolve_Delta_Array_Aggregate): In the case of a
	deep delta choice, the expected type for the expression will
	typically not be the component type of the array type, so a call
	to Analyze_And_Resolve that assumes otherwise would be an error.
	It turns out that such a call, while wrong, is usually harmless
	because the expression has already been marked as analyzed. This
	doesn't work if the aggregate occurs in a postcondition and, in
	any case, we don't want to rely on this. So do not perform the
	call in the deep case.
2023-11-21 10:57:42 +01:00
Eric Botcazou
3bf92fe3f2 ada: Small consistency fix for -gnatwv warning
The goal is to arrange for the warning to be issued consistently between
objects whose address is taken and objects whose address is not taken.

gcc/ada/

	* sem_warn.adb (Check_References.Type_OK_For_No_Value_Assigned):
	New predicate.
	(Check_References): For Warn_On_No_Value_Assigned, use the same test
	on the type in the address-not-taken and default cases.

gcc/testsuite/ChangeLog:

	* gnat.dg/warn25.adb: Add xfail.
2023-11-21 10:57:42 +01:00
Gary Dismukes
ea60a4cd19 ada: Compiler error reporting illegal prefix on legal loop iterator with "in"
During semantic analysis, the compiler fails to determine the cursor type
in the case of a generalized iterator loop with "in", in the case where the
iterator type has a parent type that is a controlled type (for example) and
its ancestor iterator interface type is given after as a progenitor. It also
improperly determines the ancestor interface type during expansion (within
Expand_Iterator_Loop_Over_Container), for both "in" and "of" iterator forms.
The FE was assuming that the iterator interface is simply the parent type
of the iterator type, but that type can occur later in the interface list,
or be inherited. A new function is added that properly locates a type's
iterator interface ancestor, if any, and is called for analysis and expansion.

gcc/ada/

	* exp_ch5.adb (Expand_Iterator_Loop_Over_Container): Retrieve the
	iteration type's iteration interface progenitor via
	Iterator_Interface_Ancestor, in the case of both "in" and "of"
	iterators. Narrow the scope of Pack, so it's declared and
	initialized only within the code related to "of" iterators, and
	change its name to Cont_Type_Pack. Adjust comments.
	* sem_ch5.adb (Get_Cursor_Type): In the case of a derived type,
	retrieve the iteration type's iterator interface progenitor (if it
	exists) via Iterator_Interface_Ancestor rather than assuming that
	the parent type is the interface progenitor.
	* sem_util.ads (Iterator_Interface_Ancestor): New function.
	* sem_util.adb (Iterator_Interface_Ancestor): New function
	returning a type's associated iterator interface type, if any, by
	collecting and traversing the type's interfaces.
2023-11-21 10:57:42 +01:00
Eric Botcazou
35510341fc ada: Fix internal error on 'Address of task component
This happens when the prefix of the selected component is of an access type,
i.e. there is an implicit dereference. because the prefix is not resolved.

gcc/ada/

	* sem_attr.adb (Resolve_Attribute) <Attribute_Address>: Remove the
	bypass for prefixes with task type.
2023-11-21 10:57:42 +01:00
Viljar Indus
3827a01766 ada: Avoid Style_Checks pragmas affecting other units
gcc/ada/

	* par.adb: Restore Style_Checks after parsing each unit.
2023-11-21 10:57:42 +01:00
Yannick Moy
2d8dc17101 ada: Fix type for SPARK expansion on deep delta aggregates
gcc/ada/

	* exp_spark.adb (Expand_SPARK_Delta_Or_Aggregate): Fix type.
2023-11-21 10:57:42 +01:00
Eric Botcazou
706535a9a2 ada: Further cleanup in finalization machinery
The bodies of generic units are instantiated separately by GNAT at the end
of the processing of the compilation unit.  This requires the deferral of
the generation of cleanups and finalization actions in enclosing scopes,
except for instantiations in generic units where they are not generated.

The criterion used to detect this latter case is Inside_A_Generic, but this
global variable is not properly updated during the instantiation of generic
bodies, leading to problems with nested instantiations, so it is changed to
Expander_Active instead.  As a matter of fact, the exact same idiom is used
a few lines above to clear the Needs_Body variable.

gcc/ada/

	* sem_ch12.adb (Analyze_Package_Instantiation): Test Expander_Active
	to detect generic contexts for the generation of cleanup actions.
2023-11-21 10:57:42 +01:00
Justin Squirek
5c7854b28f ada: Fix string indexing within GNAT.Calendar.Time_IO.Value
The patch fixes an issue in the compiler whereby calls to
GNAT.Calendar.Time_IO.Value where the actual for formal String Date with
indexing starting at any value besides one would result in a spurious runtime
exception.

gcc/ada/

	* libgnat/g-catiio.adb (Value): Modify conditionals to use 'Last
	instead of 'Length
2023-11-21 10:57:42 +01:00
Eric Botcazou
5ee80f7128 ada: Small improvement to Null_Status function
The function is used to optimize away access checks.

gcc/ada/

	* sem_util.adb (Null_Status): Deal with unchecked type conversions.
2023-11-21 10:57:41 +01:00
Eric Botcazou
6f69104c9e ada: Further cleanup in finalization machinery
This removes the specific treatment of transient scopes in initialization
procedures, which is obsolete.

gcc/ada/

	* exp_aggr.adb (Convert_To_Assignments): Do not treat initialization
	procedures specially when it comes to creating a transient scope.
	* exp_ch7.adb (Build_Finalizer.Process_Declarations): Likewise.
	* exp_util.adb (Requires_Cleanup_Actions): Likewise.
2023-11-21 10:57:41 +01:00
Doug Rupp
fee97b366b ada: Use CLOCK_MONOTONIC on VxWorks
The monotonic clock keeps track of the time that has elapsed since
system startup; that is, the value returned by clock_gettime() is the
amount of time (in seconds and nanoseconds) that has passed since the
system booted. The monotonic clock cannot be reset. As a result,
time interval measurements made relative to the monotonic clock are
not subject to errors resulting from the clock time being unexpectedly
adjusted between the interval start and end.

gcc/ada/

	* s-oscons-tmplt.c: #define CLOCK_RT_Ada "CLOCK_MONOTONIC" for
	__vxworks
2023-11-21 10:57:41 +01:00
Steve Baird
d75ca8a67e ada: Deep delta aggregates cleanup.
Cleanup after the introduction of deep delta aggregates.
Eliminate a new gnatcheck message.

gcc/ada/

	* sem_aggr.adb: Replace "not Present (...)" call with "No (...)" call.
2023-11-21 10:57:41 +01:00
Eric Botcazou
d9481c5dc0 ada: Small cleanup in finalization machinery
This removes an obsolete flag and adjusts a couple of obsolete comments.

gcc/ada/

	* gen_il-fields.ads (Opt_Field_Enum): Remove Is_Finalization_Wrapper
	* gen_il-gen-gen_nodes.adb (N_Block_Statement): Likewise.
	* sinfo.ads (Is_Finalization_Wrapper): Delete.
	* exp_ch7.adb (Build_Finalizer.Process_Declarations): Adjust comment
	and remove obsolete code testing the Is_Finalization_Wrapper flag.
	* exp_util.adb (Requires_Cleanup_Actions): Likewise.
2023-11-21 10:57:41 +01:00
Doug Rupp
d325c129d1 ada: Runtime recompilation instructions improvements.
Revise instructions to work on both cross and native targets hosted
on Linux

gcc/ada/

	* libgnat/libada.gpr: Revise section 1
2023-11-21 10:57:41 +01:00
Steve Baird
0191a24e2b ada: Deep delta aggregates
Add support for "deep" delta aggregates, a GNAT-defined language extension
conditionally enabled via the -gnatX0 switch. In a deep delta aggregate, a
delta choice may specify a subcomponent (as opposed to just a component).

gcc/ada/

	* par.adb: Add new Boolean variable Inside_Delta_Aggregate.
	* par-ch4.adb (P_Simple_Expression): Add support for a deep delta
	aggregate choice. We turn a sequence of selectors into a peculiar
	tree. We build a component (Indexed or Selected) whose prefix is
	another such component, etc. The leftmost prefix at the bottom of
	the tree has a "name" which is the first selector, without any
	further prefix. For something like "with delta (1)(2) => 3" where
	the type of the aggregate is an array of arrays of integers, we'll
	build an N_Indexed_Component whose prefix is an integer literal 1.
	This is consistent with the trees built for "regular"
	(Ada-defined) delta aggregates.
	* sem_aggr.adb (Is_Deep_Choice, Is_Root_Prefix_Of_Deep_Choice):
	New queries.
	(Resolve_Deep_Delta_Assoc): new procedure.
	(Resolve_Delta_Array_Aggregate): call Resolve_Deep_Delta_Assoc in
	deep case.
	(Resolve_Delta_Record_Aggregate): call Resolve_Deep_Delta_Assoc in
	deep case.
	(Get_Component_Type): new function replaces old Get_Component
	function.
	* sem_aggr.ads (Is_Deep_Choice, Is_Root_Prefix_Of_Deep_Choice):
	New queries.
	* exp_aggr.adb (Expand_Delta_Array_Aggregate): add nested function
	Make_Array_Delta_Assignment_LHS; call it instead of
	Make_Indexed_Component.
	(Expand_Delta_Record_Aggregate): add nested function
	Make_Record_Delta_Assignment_LHS; call it instead of
	Make_Selected_Component.
	* exp_spark.adb (Expand_SPARK_Delta_Or_Update): Insert range
	checks for indexes in deep delta aggregates.
2023-11-21 10:57:41 +01:00
Ronan Desplanques
a5fbba52e9 ada: Fix Ada.Text_IO.Delete with "encoding=8bits" form
Before this patch, on Windows, file with non-ASCII Latin1 names could be created
with Ada.Text_IO.Create by passing "encoding=8bits" through the Form
parameter and a Latin1-encoded string through the Name parameter,
but calling Ada.Text_IO.Delete on them raised an illegitimate exception.

This patch fixes this by making the wrappers of the unlink system function
aware of the encoding value passed through the Form parameter. It also
removes an unnecessary curly-brace block.

gcc/ada/

	* adaint.c (__gnat_unlink): Add new parameter and fix text
	conversion on Windows. Remove unnecessary curly braces.
	* adaint.h (__gnat_unlink): Add new parameter.
	* libgnat/i-cstrea.ads (unlink): Adapt to __gnat_unlink signature
	change.
	* libgnat/i-cstrea.adb (unlink): New Subprogram definition.
	* libgnat/s-crtl.ads (unlink): Adapt to __gnat_unlink signature
	change.
	* libgnat/s-fileio.adb (Delete): Pass encoding argument to unlink.
2023-11-21 10:57:40 +01:00
Eric Botcazou
50e0095904 ada: Fix spurious error on call with default parameter in generic package
This occurs when the default value is a function call returning a private
type, and is caused by a bad interaction between two internal mechanisms.

gcc/ada/

	* sem_ch12.adb (Save_Global_References.Set_Global_Type): Beef up
	comment about the setting of the full view.
	* sem_res.adb (Resolve_Actuals.Insert_Default): Add another bypass
	for the case of a generic context.
2023-11-21 10:57:40 +01:00
Marc Poulhiès
c6cd629ffb ada: Fix misplaced index directive in documentation
The index directive must be located before the indexed element, at least
for the generated texinfo to be correct. See:

https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-index

This was reported along with changes done in https://inbox.sourceware.org/gcc-patches/20230223102714.3606058-3-arsen@aarsen.me/

gcc/ada/

	* doc/gnat_ugn/the_gnat_compilation_model.rst: Move index
	directives.
	* gnat_ugn.texi: Regenerate.
2023-11-21 10:57:40 +01:00
Pierre-Marie de Rodat
fee5b64357 ada: Fix SCOs generation for aspect specifications
The recent overhaul for the representation of aspect specifications in
the tree broke SCOs generation: decisions that appeared in aspects were
processed twice, leading to the emission of erroneous obligations. Tweak
SCOs generation to skip aspect specifications the second time to go back
to the previous behavior.

gcc/ada/

	* par_sco.adb (Process_Decisions)<Process_Node>: Skip aspect
	specifications.
2023-11-21 10:57:40 +01:00
Ronan Desplanques
4b7d0f22b1 ada: Always use -gnatg in run-time GPR files
This patch makes it so -gnatg is always passed to the compiler when
rebuilding the run-time library with the dedicated GPR files. Before
this patch, if a user rebuilt the run-time with -XADAFLAGS=XXX where
XXX didn't include "-gnatg", the build would immediately fail. This
case occurs when following the instructions in libada.gpr, which
use '-XADAFLAGS="-gnatn"'.

gcc/ada/

	* libgnat/libgnat_common.gpr: Unconditionally pass -gnatg.
2023-11-21 10:57:40 +01:00
Marc Poulhiès
20585dc92e ada: Trivial typo fix in comment
gcc/ada/

	* exp_util.ads: Typo fix.
2023-11-21 10:57:40 +01:00
Jakub Jelinek
69813540e3 gcov: Formatting fixes
I've noticed the r14-5579 commit introduced some formatting issues,
this patch fixes what I saw.

2023-11-21  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree-profile.cc (gen_counter_update, tree_profiling): Formatting
	fixes.
libgcc/
	* libgcov.h (GCOV_SUPPORTS_ATOMIC): Formatting fixes.
2023-11-21 10:49:51 +01:00
Jakub Jelinek
1fcfd224ff testsuite: Fix up pr111309-2.c on arm [PR111309]
ARM defaults to -fshort-enums and the following testcase FAILs there in 2
lines.  The difference is that in C++, E0 has enum E type, which normally
has unsigned int underlying type, so it isn't int nor something that
promotes to int, which is why we diagnose it (in C it is promoted to int).
But with -fshort-enums, the underlying type is unsigned char in that case,
which promotes to int just fine.

The following patch adjusts the expectations, such that we don't expect
it on arm or when people manually test with -fshort-enums.

2023-11-21  Jakub Jelinek  <jakub@redhat.com>

	PR c/111309
	* c-c++-common/pr111309-2.c (foo): Don't expect errors for C++ with
	-fshort-enums if second argument is E0.
2023-11-21 10:03:26 +01:00
Jakub Jelinek
8a8a6d60c6 builtins: Fix fold_builtin_query clzg/ctzg side-effects handling [PR112639]
As the testcase shows, I've missed one spot where initially the code thinks
it could use 2 argument IFN_CLZ/IFN_CTZ form, but then verifies it can't
because it doesn't have the right target value and turns it into the
arg0 ? arg1 : .C[LT]Z (arg0)
form.  That form evaluates the argument twice though and so needs save_expr,
which I've missed to call in that case.  In other cases where it is known
from the beginning that it will be needed (e.g. the __builtin_clzg case
on types smaller than unsigned int where we'll need to add an addend
to the clz value) or the unsigned __int128 expansion called save_expr
before.

2023-11-21  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/112639
	* builtins.cc (fold_builtin_bit_query): If arg0 has side-effects, arg1
	is specified but cleared, call save_expr on arg0.

	* gcc.dg/torture/pr112639.c: New test.
2023-11-21 09:32:37 +01:00
Hongyu Wang
7ad308bd4c [APX PPX] Support Intel APX PPX
PPX stands for Push-Pop Acceleration. PUSH/PUSH2 and its corresponding POP
can be marked with a 1-bit hint to indicate that the POP reads the
value written by the PUSH from the stack. The processor tracks these marked
instructions internally and fast-forwards register data between
matching PUSH and POP instructions, without going through memory or
through the training loop of the Fast Store Forwarding Predictor (FSFP).
This feature can also be adopted to PUSH2/POP2.

For GCC, we emit explicit suffix 'p' (paired) to indicate the push/pop
pair are marked with PPX hint. To separate form original push/pop, we
add an UNSPEC on top of those PUSH/POP patterns.

In the first implementation we only emit them under prologue/epilogue
when saving/restoring callee-saved registers to make sure push/pop are
paired. So an extra flag was added to check if PPX insns can be emitted
for those register save/restore interfaces.

The PPX hint is purely a performance hint. If the 'p' suffix is not
emitted for paired push/pop, the PPX optimization will be disabled,
while program sematic will not be affected at all.

gcc/ChangeLog:

	* config/i386/i386-expand.h (gen_push): Add default bool
	parameter.
	(gen_pop): Likewise.
	* config/i386/i386-opts.h (enum apx_features): Add apx_ppx, add
	it to apx_all.
	* config/i386/i386.cc (ix86_emit_restore_reg_using_pop): Add
	ppx_p parameter for function declaration.
	(gen_push2): Add ppx_p parameter, emit push2p if ppx_p is true.
	(gen_push): Likewise.
	(ix86_emit_restore_reg_using_pop2): Likewise for pop2p.
	(ix86_emit_save_regs): Emit pushp/push2p under TARGET_APX_PPX.
	(ix86_emit_restore_reg_using_pop): Add ppx_p, emit popp insn
	and adjust cfi when ppx_p is ture.
	(ix86_emit_restore_reg_using_pop2): Add ppx_p and parse to its
	callee.
	(ix86_emit_restore_regs_using_pop2): Likewise.
	(ix86_expand_epilogue): Parse TARGET_APX_PPX to
	ix86_emit_restore_reg_using_pop.
	* config/i386/i386.h (TARGET_APX_PPX): New.
	* config/i386/i386.md (UNSPEC_APX_PPX): New unspec.
	(pushp_di): New define_insn.
	(popp_di): Likewise.
	(push2p_di): Likewise.
	(pop2p_di): Likewise.
	* config/i386/i386.opt: Add apx_ppx enum.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/apx-interrupt-1.c: Adjust option to restrict them
	under certain subfeatures.
	* gcc.target/i386/apx-push2pop2-1.c: Likewise.
	* gcc.target/i386/apx-push2pop2_force_drap-1.c: Likewise.
	* gcc.target/i386/apx-push2pop2_interrupt-1.c: Likewise.
	* gcc.target/i386/apx-ppx-1.c: New test.
2023-11-21 16:00:53 +08:00
Richard Biener
f48244fad2 middle-end/112622 - adjust arm testcases
The error message improved, adjust arm specific testcases.

	* gcc.target/arm/bfloat16_vector_typecheck_1.c: Adjust.
	* gcc.target/arm/bfloat16_vector_typecheck_2.c: Likewise.
	* gcc.target/aarch64/bfloat16_vector_typecheck_1.c: Likewise.
	* gcc.target/aarch64/bfloat16_vector_typecheck_2.c: Likewise.
2023-11-21 08:37:25 +01:00
Richard Biener
c656d268c9 tree-optimization/111970 - fix issue with SLP of emulated gather/scatter
There's a missed index adjustment for the SLP vector number when
computing the index/data vectors for emulated gather/scatter with SLP.
The following fixes this.

	PR tree-optimization/111970
	* tree-vect-stmts.cc (vectorizable_load): Fix offset calculation
	for SLP gather load.
	(vectorizable_store): Likewise for SLP scatter store.
2023-11-21 08:16:57 +01:00
Xi Ruoyao
7bf1de9186
LoongArch: Fix libgcc build failure when libc is not available
To use int64_t we included <stdint.h> in loongarch-def.h.
Unfortunately, loongarch-def.h is also used by libgcc etc., causing a
build failure when building a "stage1" cross compiler at which the
target libc is not built yet.

As int64_t is used for a C-compatible replacement of HOST_WIDE_INT, it's
not directly or indirectly referred by the target libraries.  So
guard everything requiring stdint.h with #if then they'll not block
target libraries.

gcc/ChangeLog:

	* config/loongarch/loongarch-def.h (stdint.h): Guard with #if to
	exclude it for target libraries.
	(loongarch_isa_base_features): Likewise.
	(loongarch_isa): Likewise.
	(loongarch_abi): Likewise.
	(loongarch_target): Likewise.
	(loongarch_cpu_default_isa): Likewise.
2023-11-21 11:05:11 +08:00
Juzhe-Zhong
7e2a429ae8 RISC-V: Fix reduc_run-9.c test value check bug
The current test value check is incorrect which is exposed on -march=rv64gcv_zvl256b

Confirm on X86 also abort:
[jzzhong@rios-cad121:/work/home/jzzhong/work/insn]$./a.out
------33.000000,4078.000000,45001776.000000,63369904.000000---
Aborted (core dumped)

Adapt the value check according to X86 result.

Pushed as it is obvious.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/reduc/reduc_run-9.c: Fix bug.
2023-11-21 10:38:20 +08:00
liuhongt
e5e305e604 Support reduc_{and,ior,xor}_scal_m for V4HI/V8QI/V4QImode
gcc/ChangeLog:

	PR target/112325
	* config/i386/i386-expand.cc (emit_reduc_half): Hanlde
	V8QImode.
	* config/i386/mmx.md (reduc_<code>_scal_<mode>): New expander.
	(reduc_<code>_scal_v4qi): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr112325-mmx-1.c: New test.
2023-11-21 08:34:33 +08:00
GCC Administrator
30d8188e6d Daily bump. 2023-11-21 00:17:53 +00:00
Marc Poulhiès
721cdcd1dd Trivial typo fix in variadic
Fix all occurences of varadic, except for Rust (will be part of another change).

gcc/ChangeLog:

	* config/nvptx/nvptx.h (struct machine_function): Fix typo in variadic.
	* config/nvptx/nvptx.cc (nvptx_function_arg_advance): Adjust to use fixed name.
	(nvptx_declare_function_name): Likewise.
	(nvptx_call_args): Likewise.
	(nvptx_expand_call): Likewise.

gcc/cp/ChangeLog:

	* lambda.cc (compare_lambda_sig): Fix typo in variadic.

libcpp/ChangeLog:

	* macro.cc (parse_params): Fix typo in variadic.
	(create_iso_definition): Likewise.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2023-11-20 21:39:15 +01:00
Sebastian Huber
a034cca0a2 gcov: Use unshare_expr() in gen_counter_update()
This fixes issues like this:

  gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c: In function 'main':
  gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c:19:1: error: incorrect sharing of tree nodes
  __gcov0.main[0]
  # .MEM_12 = VDEF <.MEM_9>
  __gcov0.main[0] = PROF_edge_counter_4;
  during IPA pass: profile
  gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c:19:1: internal compiler error: verify_gimple failed

Unshare the counter expression in the second gimple_build_assign() in
gen_counter_update().  This is similar to the original
gimple_gen_edge_profiler() for "ref":

void
gimple_gen_edge_profiler (int edgeno, edge e)
{
  tree one;

  one = build_int_cst (gcov_type_node, 1);

  if (flag_profile_update == PROFILE_UPDATE_ATOMIC)
[...]
  else
    {
      tree ref = tree_coverage_counter_ref (GCOV_COUNTER_ARCS, edgeno);
      tree gcov_type_tmp_var = make_temp_ssa_name (gcov_type_node,
						   NULL, "PROF_edge_counter");
      gassign *stmt1 = gimple_build_assign (gcov_type_tmp_var, ref);
      gcov_type_tmp_var = make_temp_ssa_name (gcov_type_node,
					      NULL, "PROF_edge_counter");
      gassign *stmt2 = gimple_build_assign (gcov_type_tmp_var, PLUS_EXPR,
					    gimple_assign_lhs (stmt1), one);
      gassign *stmt3 = gimple_build_assign (unshare_expr (ref),
					    gimple_assign_lhs (stmt2));
      gsi_insert_on_edge (e, stmt1);
      gsi_insert_on_edge (e, stmt2);
      gsi_insert_on_edge (e, stmt3);
    }
}

However, the orignal gimple_gen_time_profiler() did not use unshare_expr() for
the counter expression (tree_time_profiler_counter):

void
gimple_gen_time_profiler (unsigned tag)
{
[...]

  /* Emit: counters[0] = ++__gcov_time_profiler_counter.  */
  if (flag_profile_update == PROFILE_UPDATE_ATOMIC)
[...]
  else
    {
      tree tmp = make_temp_ssa_name (type, NULL, "PROF_time_profile");
      gassign *assign = gimple_build_assign (tmp, tree_time_profiler_counter);
      gsi_insert_before (&gsi, assign, GSI_NEW_STMT);

      tmp = make_temp_ssa_name (type, NULL, "PROF_time_profile");
      assign = gimple_build_assign (tmp, PLUS_EXPR, gimple_assign_lhs (assign),
				    one);
      gsi_insert_after (&gsi, assign, GSI_NEW_STMT);
      assign = gimple_build_assign (original_ref, tmp);
      gsi_insert_after (&gsi, assign, GSI_NEW_STMT);
      assign = gimple_build_assign (tree_time_profiler_counter, tmp);
      gsi_insert_after (&gsi, assign, GSI_NEW_STMT);
    }
}

gcc/ChangeLog:

	* tree-profile.cc (gen_counter_update): Use unshare_expr() for the
	counter expression in the second gimple_build_assign().
2023-11-20 19:46:35 +01:00