Commit Graph

204792 Commits

Author SHA1 Message Date
Iain Sandoe
538dcde872 configure, libquadmath: Remove unintended AC_CHECK_LIBM [PR111928]
This was a rebase error, that managed to pass testing on Darwin and
Linux (but fails on bare metal).

	PR libquadmath/111928

libquadmath/ChangeLog:

	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Remove AC_CHECK_LIBM.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2023-10-23 14:14:01 +01:00
Oleg Endo
267e369afb SH: Fix PR 111001
gcc/ChangeLog:

	PR target/111001
	* config/sh/sh_treg_combine.cc (sh_treg_combine::record_set_of_reg):
	Skip over nop move insns.
2023-10-23 22:11:01 +09:00
Tamar Christina
9ed6b22eb4 middle-end: don't keep .MEM guard nodes for PHI nodes who dominate loop [PR111860]
The previous patch tried to remove PHI nodes that dominated the first loop,
however the correct fix is to only remove .MEM nodes.

This patch thus makes the condition a bit stricter and only tries to remove
MEM phi nodes.

I couldn't figure out a way to easily determine if a particular PHI is vUSE
related, so the patch does:

1. check if the definition is a vDEF and not defined in main loop.
2. check if the definition is a PHI and not defined in main loop.
3. check if the definition is a default definition.

For no 2 and 3 we may misidentify the PHI, in both cases the value is defined
outside of the loop version block which also makes it ok to remove.

gcc/ChangeLog:

	PR tree-optimization/111860
	* tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
	Drop .MEM nodes only.

gcc/testsuite/ChangeLog:

	PR tree-optimization/111860
	* gcc.dg/vect/pr111860-2.c: New test.
	* gcc.dg/vect/pr111860-3.c: New test.
2023-10-23 14:08:10 +01:00
Andrew Pinski
1acd457643 move the (a-b) CMP 0 ? (a-b) : (b-a) optimization from fold_cond_expr_with_comparison to match
This patch moves the `(a-b) CMP 0 ? (a-b) : (b-a)` optimization
from fold_cond_expr_with_comparison to match.

Bootstrapped and tested on x86_64-linux-gnu.

Changes in:
v2: Removes `(a == b) ? 0 : (b - a)` handling since it was handled
    via r14-3606-g3d86e7f4a8ae
    Change zerop to integer_zerop for `(a - b) == 0 ? 0 : (b - a)`,
    Add `(a - b) != 0 ? (a - b) : 0` handling.

gcc/ChangeLog:

	* match.pd (`(A - B) CMP 0 ? (A - B) : (B - A)`):
	New patterns.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/phi-opt-38.c: New test.
2023-10-23 03:55:15 -07:00
Andrew Pinski
85e930ac85 Use error_mark_node after error in convert
While working on PR c/111903, I Noticed that
convert will convert integer_zero_node to that
type after an error instead of returning error_mark_node.
From what I can tell this was the old way of not having
error recovery since other places in this file does return
error_mark_node and the places I am replacing date from
when the file was imported into the repro (either via a gcc2 merge
or earlier).

I also had to update the objc front-end to allow for the error_mark_node
change, I suspect you could hit the ICE without this change though.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* convert.cc (convert_to_pointer_1): Return error_mark_node
	after an error.
	(convert_to_real_1): Likewise.
	(convert_to_integer_1): Likewise.
	(convert_to_complex_1): Likewise.

gcc/objc/ChangeLog:

	* objc-gnu-runtime-abi-01.cc (build_objc_method_call): Allow
	for error_operand after call to build_c_cast.
	* objc-next-runtime-abi-01.cc (build_objc_method_call): Likewise.
	* objc-next-runtime-abi-02.cc (build_v2_build_objc_method_call): Likewise.
2023-10-23 03:55:15 -07:00
Andrew Pinski
13c0d05247 convert_to_complex vs invalid_conversion [PR111903]
convert_to_complex when creating a COMPLEX_EXPR does
not currently check if either the real or imag parts
was not error_mark_node. This later on confuses the gimpilfier
when there was a SAVE_EXPR wrapped around that COMPLEX_EXPR.
The simple fix is after calling convert inside convert_to_complex_1,
check that the either result was an error_operand and return
an error_mark_node in that case.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR c/111903

gcc/ChangeLog:

	* convert.cc (convert_to_complex_1): Return
	error_mark_node if either convert was an error
	when converting from a scalar.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/float16-8.c: New test.
2023-10-23 03:54:54 -07:00
Richard Biener
d96bd4aade tree-optimization/111917 - bougs IL after guard hoisting
The unswitching code to hoist guards inserts conditions in wrong
places.  The following fixes this, simplifying code.

	PR tree-optimization/111917
	* tree-ssa-loop-unswitch.cc (hoist_guard): Always insert
	new conditional after last stmt.

	* gcc.dg/torture/pr111917.c: New testcase.
2023-10-23 12:32:00 +02:00
Juzhe-Zhong
0c4bd1321a RISC-V: Fix ICE for the fusion case from vsetvl to scalar move[PR111927]
ICE:

during RTL pass: vsetvl
<source>: In function 'riscv_lms_f32':
<source>:240:1: internal compiler error: in merge, at config/riscv/riscv-vsetvl.cc:1997
  240 | }

In general compatible_p (avl_equal_p) has:

    if (next.has_vl () && next.vl_used_by_non_rvv_insn_p ())
      return false;

Don't fuse AVL of vsetvl if the VL operand is used by non-RVV instructions.

It is reasonable to add it into 'can_use_next_avl_p' since we don't want to
fuse AVL of vsetvl into a scalar move instruction which doesn't demand AVL.
And after the fusion, we will alway use compatible_p to check whether the demand
is correct or not.

	PR target/111927

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc: Fix bug.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/pr111927.c: New test.
2023-10-23 17:59:42 +08:00
Pan Li
09c9de0607 RISC-V: Remove unnecessary asm check for vec cvt
The vsetvl asm check is unnecessary for the vector convert. We
should be focus for constrait and leave the vsetvl test to the
vsetvl pass.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/unop/cvt-0.c: Remove the vsetvl
	asm check from func body.
	* gcc.target/riscv/rvv/autovec/unop/cvt-1.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-23 17:58:02 +08:00
Jan Beulich
0093821426 libatomic: drop redundant all-multi command
./multilib.am already specifies this same command, and make warns about
the earlier one being ignored when seeing the later one. All that needs
retaining to still satisfy the preceding comment is the extra
dependency.

libatomic/

	* Makefile.am (all-multi): Drop commands.
	* Makefile.in: Update accordingly.
2023-10-23 10:23:14 +02:00
Pan Li
996785db50 RISC-V: Bugfix for merging undef tmp register for trunc
For trunc function autovec, there will be one step like below take MU
for the merge operand.

rtx tmp = gen_reg_rtx (vec_int_mode);
emit_vec_cvt_x_f_rtz (tmp, op_1, mask, vec_fp_mode);

The MU will leave the tmp (aka dest register) register unmasked elements
unchanged and it is undefined here. This patch would like to adjust the
MU to MA.

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (emit_vec_cvt_x_f_rtz): Add insn type
	arg.
	(expand_vec_trunc): Take MA instead of MU for cvt_x_f_rtz.

Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-23 16:00:32 +08:00
Xi Ruoyao
e1b1cba141
LoongArch: Document -mexplicit-relocs={auto,none,always}
gcc/ChangeLog:

	* doc/invoke.texi (-mexplicit-relocs=style): Document.
	(-mexplicit-relocs): Document as an alias of
	-mexplicit-relocs=always.
	(-mno-explicit-relocs): Document as an alias of
	-mexplicit-relocs=none.
	(-mcmodel=extreme): Mention -mexplicit-relocs=always instead of
	-mexplicit-relocs.
2023-10-23 15:30:19 +08:00
Xi Ruoyao
83e24e8c1e
LoongArch: Use explicit relocs for addresses only used for one load or store with -mexplicit-relocs=auto and -mcmodel={normal,medium}
In these cases, if we use explicit relocs, we end up with 2
instructions:

    pcalau12i    t0, %pc_hi20(x)
    ld.d         t0, t0, %pc_lo12(x)

If we use la.local pseudo-op, in the best scenario (x is in +/- 2MiB
range) we still have 2 instructions:

    pcaddi       t0, %pcrel_20(x)
    ld.d         t0, t0, 0

If x is out of the range we'll have 3 instructions.  So for these cases
just emit machine instructions with explicit relocs.

gcc/ChangeLog:

	* config/loongarch/predicates.md (symbolic_pcrel_operand): New
	predicate.
	* config/loongarch/loongarch.md (define_peephole2): Optimize
	la.local + ld/st to pcalau12i + ld/st if the address is only used
	once if -mexplicit-relocs=auto and -mcmodel=normal or medium.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/explicit-relocs-auto-single-load-store.c:
	New test.
	* gcc.target/loongarch/explicit-relocs-auto-single-load-store-no-anchor.c:
	New test.
2023-10-23 15:30:19 +08:00
Xi Ruoyao
95db62f4ad
LoongArch: Use explicit relocs for TLS access with -mexplicit-relocs=auto
The linker does not know how to relax TLS access for LoongArch, so let's
emit machine instructions with explicit relocs for TLS.

gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_explicit_relocs_p):
	Return true for TLS symbol types if -mexplicit-relocs=auto.
	(loongarch_call_tls_get_addr): Replace TARGET_EXPLICIT_RELOCS
	with la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE.
	(loongarch_legitimize_tls_address): Likewise.
	* config/loongarch/loongarch.md (@tls_low<mode>): Remove
	TARGET_EXPLICIT_RELOCS from insn condition.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c: New
	test.
	* gcc.target/loongarch/explicit-relocs-auto-tls-le-ie.c: New
	test.
2023-10-23 15:30:19 +08:00
Xi Ruoyao
8811630df8
LoongArch: Use explicit relocs for GOT access when -mexplicit-relocs=auto and LTO during a final link with linker plugin
If we are performing LTO for a final link and linker plugin is enabled,
then we are sure any GOT access may resolve to a symbol out of the link
unit (otherwise the linker plugin will tell us the symbol should be
resolved locally and we'll use PC-relative access instead).

Produce machine instructions with explicit relocs instead of la.global
for better scheduling.

gcc/ChangeLog:

	* config/loongarch/loongarch-protos.h
	(loongarch_explicit_relocs_p): Declare new function.
	* config/loongarch/loongarch.cc (loongarch_explicit_relocs_p):
	Implement.
	(loongarch_symbol_insns): Call loongarch_explicit_relocs_p for
	SYMBOL_GOT_DISP, instead of using TARGET_EXPLICIT_RELOCS.
	(loongarch_split_symbol): Call loongarch_explicit_relocs_p for
	deciding if return early, instead of using
	TARGET_EXPLICIT_RELOCS.
	(loongarch_output_move): CAll loongarch_explicit_relocs_p
	instead of using TARGET_EXPLICIT_RELOCS.
	* config/loongarch/loongarch.md (*low<mode>): Remove
	TARGET_EXPLICIT_RELOCS from insn condition.
	(@ld_from_got<mode>): Likewise.
	* config/loongarch/predicates.md (move_operand): Call
	loongarch_explicit_relocs_p instead of using
	TARGET_EXPLICIT_RELOCS.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/explicit-relocs-auto-lto.c: New test.
2023-10-23 15:30:19 +08:00
Xi Ruoyao
93a46d18f5
LoongArch: Add enum-style -mexplicit-relocs= option
To take a better balance between scheduling and relaxation when -flto is
enabled, add three-way -mexplicit-relocs={auto,none,always} options.
The old -mexplicit-relocs and -mno-explicit-relocs options are still
supported, they are mapped to -mexplicit-relocs=always and
-mexplicit-relocs=none.

The default choice is determined by probing assembler capabilities at
build time.  If the assembler does not supports explicit relocs at all,
the default will be none; if it supports explicit relocs but not
relaxation, the default will be always; if both explicit relocs and
relaxation are supported, the default will be auto.

Currently auto is same as none.  We will make auto more clever in
following changes.

gcc/ChangeLog:

	* config/loongarch/genopts/loongarch-strings: Add strings for
	-mexplicit-relocs={auto,none,always}.
	* config/loongarch/genopts/loongarch.opt.in: Add options for
	-mexplicit-relocs={auto,none,always}.
	* config/loongarch/loongarch-str.h: Regenerate.
	* config/loongarch/loongarch.opt: Regenerate.
	* config/loongarch/loongarch-def.h
	(EXPLICIT_RELOCS_AUTO): Define.
	(EXPLICIT_RELOCS_NONE): Define.
	(EXPLICIT_RELOCS_ALWAYS): Define.
	(N_EXPLICIT_RELOCS_TYPES): Define.
	* config/loongarch/loongarch.cc
	(loongarch_option_override_internal): Error out if the old-style
	-m[no-]explicit-relocs option is used with
	-mexplicit-relocs={auto,none,always} together.  Map
	-mno-explicit-relocs to -mexplicit-relocs=none and
	-mexplicit-relocs to -mexplicit-relocs=always for backward
	compatibility.  Set a proper default for -mexplicit-relocs=
	based on configure-time probed linker capability.  Update a
	diagnostic message to mention -mexplicit-relocs=always instead
	of the old-style -mexplicit-relocs.
	(loongarch_handle_model_attribute): Update a diagnostic message
	to mention -mexplicit-relocs=always instead of the old-style
	-mexplicit-relocs.
	* config/loongarch/loongarch.h (TARGET_EXPLICIT_RELOCS): Define.
2023-10-23 15:30:19 +08:00
Juzhe-Zhong
4cd4c34acd RISC-V: Fix typo[VSETVL PASS]
When fixing an issue, I find there is a typo in VSETVL PASS.

Change 'use_by' into 'used_by'.

Committed it as it is very obvious.

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (pre_vsetvl::fuse_local_vsetvl_info): Fix typo.
	(pre_vsetvl::pre_global_vsetvl_info): Ditto.
2023-10-23 15:25:35 +08:00
Florian Weimer
0e29c6f655 gcc.c-torture/execute/builtins/pr93262-chk.c: Remove return statement
The main_test function returns void, so return with an expression
is a constraint violation.  The test case still fails with this
change applied before the fix for PR 93262 in r14-4813.

gcc/testsuite/

	* gcc.c-torture/execute/builtins/pr93262-chk.c (main_test):
	Remove unnecessary return statement.
2023-10-23 09:23:05 +02:00
Pan Li
c2d41cdfea RISC-V: Remove unnecessary asm check for binop constraint
The vsetvl asm check is unnecessary for the binop constraint. We
should be focus for constrait and leave the vsetvl test to the
vsetvl pass.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/binop_vv_constraint-1.c: Remove the
	vsetvl asm check from func body.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-1.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-10.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-11.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-12.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-129.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-13.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-130.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-131.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-133.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-134.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-135.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-14.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-15.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-153.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-154.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-155.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-158.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-16.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-17.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-171.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-172.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-173.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-174.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-18.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-19.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-2.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-20.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-21.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-22.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-23.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-24.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-25.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-26.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-27.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-28.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-29.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-3.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-30.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-31.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-32.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-33.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-34.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-35.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-36.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-37.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-38.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-39.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-4.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-40.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-41.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-42.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-43.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-44.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-5.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-6.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-7.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-8.c: Ditto.
	* gcc.target/riscv/rvv/base/binop_vx_constraint-9.c: Ditto.
	* gcc.target/riscv/rvv/base/shift_vx_constraint-1.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vv_constraint-1.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vv_constraint-2.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vv_constraint-3.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vv_constraint-4.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vv_constraint-5.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vv_constraint-6.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vx_constraint-1.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vx_constraint-8.c: Ditto.
	* gcc.target/riscv/rvv/base/ternop_vx_constraint-9.c: Ditto.
	* gcc.target/riscv/rvv/base/unop_v_constraint-1.c: Ditto.
	* gcc.target/riscv/rvv/base/unop_v_constraint-2.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-23 14:28:12 +08:00
Pan Li
7846d22887 RISC-V: Remove unnecessary asm check for rounding autovec
The vsetvl asm check is unnecessary for the rounding function autovec.
These rounding test cases should focus on the rounding insn sequence.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/unop/bswap16-0.c: Remove the
	vsetvl check.
	* gcc.target/riscv/rvv/autovec/unop/math-ceil-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-ceil-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-ceil-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-ceil-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-floor-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-floor-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-floor-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-floor-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-iceil-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-ifloor-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-irint-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-iround-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-lceil-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-lceil-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-lfloor-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-lfloor-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-llceil-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-llfloor-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-llrint-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-llround-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-lrint-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-lrint-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-lround-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-lround-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-nearbyint-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-nearbyint-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-nearbyint-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-nearbyint-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-rint-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-rint-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-rint-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-rint-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-round-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-round-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-round-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-round-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-roundeven-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-roundeven-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-roundeven-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-roundeven-3.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-trunc-0.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-trunc-1.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-trunc-2.c: Ditto.
	* gcc.target/riscv/rvv/autovec/unop/math-trunc-3.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-23 10:43:18 +08:00
Juzhe-Zhong
75322a6d0c RISC-V: Fix AVL_TYPE attribute of tuple mode mov<mode>
The tuple mode mov<mode> pattern doesn't have avl_type so it is invalid attribute.

gcc/ChangeLog:

	* config/riscv/vector.md: Fix avl_type attribute of tuple mov<mode>.
2023-10-23 10:26:11 +08:00
Kewen Lin
1908775f79 vect: Cost adjacent vector loads/stores together [PR111784]
As comments[1][2], this patch is to change the costing way
on some adjacent vector loads/stores from costing one by
one to costing them together with the total number once.

It helps to fix the exposed regression PR111784 on aarch64,
as aarch64 specific costing could make different decisions
according to the different costing ways (counting with total
number vs. counting one by one).  Based on a reduced test
case from PR111784, only considering vec_num can fix the
regression already, but vector loads/stores in regard to
ncopies are also adjacent accesses, so they are considered
as well.

btw, this patch leaves the costing on dr_explicit_realign
and dr_explicit_realign_optimized alone to make it simple.
The costing way change can cause the differences for them
since there is one costing depending on targetm.vectorize.
builtin_mask_for_load and it's costed according to the
calling times.  IIUC, these two dr_alignment_support are
mainly used for old Power? (only having 16 bytes aligned
vector load/store but no unaligned vector load/store).

[1] https://gcc.gnu.org/pipermail/gcc-patches/2023-September/630742.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2023-September/630744.html

	PR tree-optimization/111784

gcc/ChangeLog:

	* tree-vect-stmts.cc (vectorizable_store): Adjust costing way for
	adjacent vector stores, by costing them with the total number
	rather than costing them one by one.
	(vectorizable_load): Adjust costing way for adjacent vector
	loads, by costing them with the total number rather than costing
	them one by one.
2023-10-22 21:18:40 -05:00
Haochen Jiang
1df490edd4 i386: Prevent splitting to xmm16+ when !TARGET_AVX512VL
Currently, there will be a chance in split to use x/ymm16+ w/o AVX512VL,
which finally leads to an ICE as pr111753 does.

This patch aims to fix that.

gcc/ChangeLog:

	PR target/111753
	* config/i386/i386.cc (ix86_standard_x87sse_constant_load_p):
	Do not split to xmm16+ when !TARGET_AVX512VL.

gcc/testsuite/ChangeLog:

	PR target/111753
	* gcc.target/i386/pr111753.c: New test.
2023-10-23 10:02:37 +08:00
Pan Li
85858c71a8 RISC-V: Bugfix for merging undefined tmp register in math
For math function autovec, there will be one step like

rtx tmp = gen_reg_rtx (vec_int_mode);
emit_vec_cvt_x_f (tmp, op_1, mask, UNARY_OP_TAMU_FRM_DYN, vec_fp_mode);

The MU will leave the tmp (aka dest register) register unmasked elements
unchanged and it is undefined here. This patch would like to adjust the
MU to MA.

gcc/ChangeLog:

	* config/riscv/riscv-protos.h (enum insn_type): Add new type
	values.
	* config/riscv/riscv-v.cc (emit_vec_cvt_x_f): Add undef merge
	operand handling.
	(expand_vec_ceil): Take MA instead of MU for tmp register.
	(expand_vec_floor): Ditto.
	(expand_vec_nearbyint): Ditto.
	(expand_vec_rint): Ditto.
	(expand_vec_round): Ditto.
	(expand_vec_roundeven): Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-23 09:50:06 +08:00
Ian Lance Taylor
a6e74b0b33 compiler: remove traverse_assignments pass
The last caller was removed in https://go.dev/cl/18261 in 2016.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536637
2023-10-22 18:48:11 -07:00
Ian Lance Taylor
1a1fba1e25 compiler: remove name_ field from Type_switch_statement
It's not used for anything.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536636
2023-10-22 18:45:50 -07:00
Ian Lance Taylor
b513aa235d compiler: pass Gogo to determine types pass
Also pass Gogo to the type verification pass.

This is a refactoring that does not change the compiler behavior.
This is in preparation for future CLs that rearrange the pass ordering.

This introduces one new call to go_get_gogo, which will be removed in
a future CL.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536635
2023-10-22 18:43:07 -07:00
Lulu Cheng
5697ed0327 LoongArch: Define macro CLEAR_INSN_CACHE.
LoongArch's microstructure ensures cache consistency by hardware.
Due to out-of-order execution, "ibar" is required to ensure the visibility of the
store (invalidated icache) executed by this CPU before "ibar" (to the instance).
"ibar" will not invalidate the icache, so the start and end parameters are not Affect
"ibar" performance.

gcc/ChangeLog:

	* config/loongarch/loongarch.h (CLEAR_INSN_CACHE): New definition.
2023-10-23 09:26:43 +08:00
Haochen Gui
f08ca5903c Expand: Enable vector mode for by pieces compares
Vector mode compare instructions are efficient for equality compare on
rs6000. This patch refactors the codes of by pieces operation to enable
vector mode for compare.

gcc/
	PR target/111449
	* expr.cc (can_use_qi_vectors): New function to return true if
	we know how to implement OP using vectors of bytes.
	(qi_vector_mode_supported_p): New function to check if optabs
	exists for the mode and certain by pieces operations.
	(widest_fixed_size_mode_for_size): Replace the second argument
	with the type of by pieces operations.  Call can_use_qi_vectors
	and qi_vector_mode_supported_p to do the check.  Call
	scalar_mode_supported_p to check if the scalar mode is supported.
	(by_pieces_ninsns): Pass the type of by pieces operation to
	widest_fixed_size_mode_for_size.
	(class op_by_pieces_d): Remove m_qi_vector_mode.  Add m_op to
	record the type of by pieces operations.
	(op_by_pieces_d::op_by_pieces_d): Change last argument to the
	type of by pieces operations, initialize m_op with it.  Pass
	m_op to function widest_fixed_size_mode_for_size.
	(op_by_pieces_d::get_usable_mode): Pass m_op to function
	widest_fixed_size_mode_for_size.
	(op_by_pieces_d::smallest_fixed_size_mode_for_size): Call
	can_use_qi_vectors and qi_vector_mode_supported_p to do the
	check.
	(op_by_pieces_d::run): Pass m_op to function
	widest_fixed_size_mode_for_size.
	(move_by_pieces_d::move_by_pieces_d): Set m_op to MOVE_BY_PIECES.
	(store_by_pieces_d::store_by_pieces_d): Set m_op with the op.
	(can_store_by_pieces): Pass the type of by pieces operations to
	widest_fixed_size_mode_for_size.
	(clear_by_pieces): Initialize class store_by_pieces_d with
	CLEAR_BY_PIECES.
	(compare_by_pieces_d::compare_by_pieces_d): Set m_op to
	COMPARE_BY_PIECES.
2023-10-23 09:17:17 +08:00
liuhongt
dbde384bd5 Avoid compile time hog on vect_peel_nonlinear_iv_init for nonlinear induction vec_step_op_mul when iteration count is too big.
There's loop in vect_peel_nonlinear_iv_init to get init_expr *
pow (step_expr, skip_niters). When skipn_iters is too big, compile time
hogs. To avoid that, optimize init_expr * pow (step_expr, skip_niters) to
init_expr << (exact_log2 (step_expr) * skip_niters) when step_expr is
pow of 2, otherwise give up vectorization when skip_niters >=
TYPE_PRECISION (TREE_TYPE (init_expr)).

Also give up vectorization when niters_skip is negative which will be
used for fully masked loop.

gcc/ChangeLog:

	PR tree-optimization/111820
	PR tree-optimization/111833
	* tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p): Give
	up vectorization for nonlinear iv vect_step_op_mul when
	step_expr is not exact_log2 and niters is greater than
	TYPE_PRECISION (TREE_TYPE (step_expr)). Also don't vectorize
	for nagative niters_skip which will be used by fully masked
	loop.
	(vect_can_advance_ivs_p): Pass whole phi_info to
	vect_can_peel_nonlinear_iv_p.
	* tree-vect-loop.cc (vect_peel_nonlinear_iv_init): Optimize
	init_expr * pow (step_expr, skipn) to init_expr
	<< (log2 (step_expr) * skipn) when step_expr is exact_log2.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr111820-1.c: New test.
	* gcc.target/i386/pr111820-2.c: New test.
	* gcc.target/i386/pr111820-3.c: New test.
	* gcc.target/i386/pr103144-mul-1.c: Adjust testcase.
	* gcc.target/i386/pr103144-mul-2.c: Adjust testcase.
2023-10-23 09:15:36 +08:00
liuhongt
93a65e0adb Remove unused mmx_pinsrw.
gcc/ChangeLog:

	* config/i386/mmx.md (mmx_pinsrw): Remove.
2023-10-23 09:14:42 +08:00
GCC Administrator
3b6327461d Daily bump. 2023-10-23 00:16:43 +00:00
Andrew Pinski
bcc5054b36 aarch64: Emit csinv again for a ? ~b : b [PR110986]
After r14-3110-g7fb65f10285, the canonical form for
`a ? ~b : b` changed to be `-(a) ^ b` that means
for aarch64 we need to add a few new insn patterns
to be able to catch this and change it to be
what is the canonical form for the aarch64 backend.
A secondary pattern was needed to support a zero_extended
form too; this adds a testcase for all 3 cases.

Bootstrapped and tested on aarch64-linux-gnu with no regressions.

	PR target/110986

gcc/ChangeLog:

	* config/aarch64/aarch64.md (*cmov<mode>_insn_insv): New pattern.
	(*cmov_uxtw_insn_insv): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/cond_op-1.c: New test.
2023-10-22 15:32:44 -07:00
Iain Buclaw
c9ae68f97e d: Merge upstream dmd f4be7f6f7b.
D front-end changes:

    - Fix bootstrap failure with i686-darwin9.
      ```
      Undefined symbols for architecture i386:
          "gendocfile", referenced from:
          __ZL20d_generate_ddoc_fileP6ModuleR9OutBuffer in d-lang.o
      ld: symbol(s) not found for architecture i386
      ```
gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd f4be7f6f7b.
	* Make-lang.in (D_FRONTEND_OBJS): Rename d/root-rootobject.o to
	d/rootobject.o.
2023-10-22 22:56:36 +02:00
Patrick Palka
80ddcb9c8f objc++: type/expr tsubst conflation [PR111920]
After r14-4796-g3e3d73ed5e85e7, tsubst_copy_and_build (now named
tsubst_expr) no longer dispatches to tsubst for type trees, and
callers have to do it themselves if appropriate.  This patch makes
some overlooked adjustments to Objective-C++-specific code paths.

	PR objc++/111920

gcc/cp/ChangeLog:

	* pt.cc (tsubst_expr) <case AT_ENCODE_EXPR>: Use tsubst instead
	of tsubst_expr.

gcc/objcp/ChangeLog:

	* objcp-lang.cc (objcp_tsubst_expr) <case CLASS_REFERENCE_EXPR>:
	Use tsubst instead of tsubst_expr for type operands.
2023-10-22 16:13:33 -04:00
Francois-Xavier Coudert
47b634a308 Doc: document the new Darwin options
gcc/ChangeLog:

	* doc/invoke.texi: Document the new -nodefaultrpaths option.
	* doc/install.texi: Document the new --with-darwin-extra-rpath
	option.
2023-10-22 19:31:24 +01:00
Iain Sandoe
a0673ec5f9 Testsuite: allow non-installed testing on darwin
DYLD_LIBRARY_PATH is now removed from the environment for all system
tools, including the shell. Adapt the testsuite and pass the right
options to allow testing, even when the compiler and libraries have not
been installed.

gcc/ChangeLog:

	* Makefile.in: set ENABLE_DARWIN_AT_RPATH in site.tmp.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/caf.exp: Correctly set
	libatomic flags.
	* gfortran.dg/dg.exp: Likewise.
	* lib/asan-dg.exp: Set correct -B flags.
	* lib/atomic-dg.exp: Likewise.
	* lib/target-libpath.exp: Handle ENABLE_DARWIN_AT_RPATH.

libatomic/ChangeLog:

	* testsuite/lib/libatomic.exp: Pass correct flags on darwin.

libffi/ChangeLog:

	* testsuite/lib/libffi.exp: Likewise.

libitm/ChangeLog:

	* testsuite/lib/libitm.exp: Likewise.
	* testsuite/libitm.c++/c++.exp: Likewise.
2023-10-22 19:30:54 +01:00
Iain Sandoe
8fe73ef278 Darwin, rpaths: Add --with-darwin-extra-rpath.
This is provided to allow distributions to add a single additional
runpath to allow for cases where the installed GCC library directories
are then symlinked to a common dirctory outside of any of the GCC
installations.

For example:

/opt/distro/lib:
  libgfortran.dylib -> /opt/distro/lib/gcc-11.3/lib/libgfortran.dylib

So that libraries which are designed to be found in the runpath we would then
add --with-darwin-add-rpath=/opt/distro/lib to the configure line.

This patch makes the configuration a little more forgiving of using
--disable-darwin-at-rpath (although for platform versions >= 10.11 this will
result in misconfigured target libraries).

gcc/ChangeLog:

	* configure.ac: Add --with-darwin-extra-rpath option.
	* config/darwin.h: Handle DARWIN_EXTRA_RPATH.
	* config.in: Regenerate.
	* configure: Regenerate.
2023-10-22 19:30:29 +01:00
Iain Sandoe
6a6d3817af Config,Darwin: Allow for configuring Darwin to use embedded runpath.
Recent Darwin versions place contraints on the use of run paths
specified in environment variables.  This breaks some assumptions
in the GCC build.

This change allows the user to configure a Darwin build to use
'@rpath/libraryname.dylib' in library names and then to add an
embedded runpath to executables (and libraries with dependents).

The embedded runpath is added by default unless the user adds
'-nodefaultrpaths' to the link line.

For an installed compiler, it means that any executable built with
that compiler will reference the runtimes installed with the
compiler (equivalent to hard-coding the library path into the name
of the library).

During build-time configurations  any "-B" entries will be added to
the runpath thus the newly-built libraries will be found by exes.

Since the install name is set in libtool, that decision needs to be
available here (but might also cause dependent ones in Makefiles,
so we need to export a conditional).

This facility is not available for Darwin 8 or earlier, however the
existing environment variable runpath does work there.

We default this on for systems where the external DYLD_LIBRARY_PATH
does not work and off for Darwin 8 or earlier.  For systems that can
use either method, if the value is unset, we use the default (which
is currently DYLD_LIBRARY_PATH).

ChangeLog:

	* configure: Regenerate.
	* configure.ac: Do not add default runpaths to GCC exes
	when we are building -static-libstdc++/-static-libgcc (the
	default).
	* libtool.m4: Add 'enable-darwin-at-runpath'.  Act  on the
	enable flag to alter Darwin libraries to use @rpath names.

gcc/ChangeLog:

	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
	* config/darwin.h: Handle Darwin rpaths.
	* config/darwin.opt: Handle Darwin rpaths.
	* Makefile.in:  Handle Darwin rpaths.

gcc/ada/ChangeLog:

	* gcc-interface/Makefile.in: Handle Darwin rpaths.

gcc/jit/ChangeLog:
	* Make-lang.in: Handle Darwin rpaths.

libatomic/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libbacktrace/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libcc1/ChangeLog:

	* configure: Regenerate.

libffi/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

libgcc/ChangeLog:

	* config/t-slibgcc-darwin: Generate libgcc_s
	with an @rpath name.
	* config.host: Handle Darwin rpaths.

libgfortran/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths

libgm2/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
	* libm2cor/Makefile.am: Handle Darwin rpaths.
	* libm2cor/Makefile.in: Regenerate.
	* libm2iso/Makefile.am: Handle Darwin rpaths.
	* libm2iso/Makefile.in: Regenerate.
	* libm2log/Makefile.am: Handle Darwin rpaths.
	* libm2log/Makefile.in: Regenerate.
	* libm2min/Makefile.am: Handle Darwin rpaths.
	* libm2min/Makefile.in: Regenerate.
	* libm2pim/Makefile.am: Handle Darwin rpaths.
	* libm2pim/Makefile.in: Regenerate.

libgomp/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths

libitm/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libobjc/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libphobos/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
	* libdruntime/Makefile.am: Handle Darwin rpaths.
	* libdruntime/Makefile.in: Regenerate.
	* src/Makefile.am: Handle Darwin rpaths.
	* src/Makefile.in: Regenerate.

libquadmath/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libsanitizer/ChangeLog:

	* asan/Makefile.am: Handle Darwin rpaths.
	* asan/Makefile.in: Regenerate.
	* configure: Regenerate.
	* hwasan/Makefile.am: Handle Darwin rpaths.
	* hwasan/Makefile.in: Regenerate.
	* lsan/Makefile.am: Handle Darwin rpaths.
	* lsan/Makefile.in: Regenerate.
	* tsan/Makefile.am: Handle Darwin rpaths.
	* tsan/Makefile.in: Regenerate.
	* ubsan/Makefile.am: Handle Darwin rpaths.
	* ubsan/Makefile.in: Regenerate.

libssp/ChangeLog:

	* Makefile.am: Handle Darwin rpaths.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

libstdc++-v3/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
	* src/Makefile.am: Handle Darwin rpaths.
	* src/Makefile.in: Regenerate.

libvtv/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

lto-plugin/ChangeLog:
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.

zlib/ChangeLog:
	* configure: Regenerate.
	* configure.ac: Handle Darwin rpaths.
2023-10-22 19:30:02 +01:00
Iain Sandoe
829b0c4cba Driver: Provide a spec to insert rpaths for compiler lib dirs.
This provides a spec to insert "-rpath DDD" for each DDD corresponding
to a compiler startfile directory.  This allows a target to use @rpath
as the install path for libraries, and have the compiler provide the
necessary rpath to handle this.

Embed real paths, not relative ones.

We embed a runpath for every path in which libraries might be found.  This
change ensures that we embed the actual real path and not a relative one from
the compiler's version-specific directory.

e.g.
/opt/distro/gcc-11-3Dr0/lib

instead of:
/opt/distro/gcc-11-3Dr0/lib/gcc/x86_64-apple-darwin19/11.3.0/../../..

This ensures that if we install, for example, 11.4.0 (and delete the 11.3.0
installation) exes built by 11.3 would continue to function (providing, of course
that 11.4 does not bump any SO names).

gcc/ChangeLog:
	* gcc.cc (RUNPATH_OPTION): New.
	(do_spec_1): Provide '%P' as a spec to insert rpaths for
	each compiler startfile path.
2023-10-22 19:26:45 +01:00
Andrew Burgess
8abddb187b libgcc: support heap-based trampolines
Add support for heap-based trampolines on x86_64-linux, aarch64-linux,
and x86_64-darwin. Implement the __builtin_nested_func_ptr_created and
__builtin_nested_func_ptr_deleted functions for these targets.

Co-Authored-By: Maxim Blinov <maxim.blinov@embecosm.com>
Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

libgcc/ChangeLog:

	* libgcc2.h (__builtin_nested_func_ptr_created): Declare.
	(__builtin_nested_func_ptr_deleted): Declare.
	* libgcc-std.ver.in: Add the new symbols.
	* config/aarch64/heap-trampoline.c: Implement heap-based
	trampolines for aarch64.
	* config/aarch64/t-heap-trampoline: Add rule to build
	config/aarch64/heap-trampoline.c
	* config/i386/heap-trampoline.c: Implement heap-based
	trampolines for x86_64.
	* config/i386/t-heap-trampoline: Add rule to build
	config/i386/heap-trampoline.cc
	* config.host: Handle --enable-heap-trampolines on
	x86_64-*-linux*, aarch64-*-linux*, x86_64-*-darwin*.
2023-10-22 14:01:47 +01:00
Andrew Burgess
cbf6da166e target: Support heap-based trampolines
Enable -ftrampoline-impl=heap by default if we are on macOS 11
or later.

Co-Authored-By: Maxim Blinov <maxim.blinov@embecosm.com>
Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>

gcc/ChangeLog:

	* config.gcc: Default to heap trampolines on macOS 11 and above.
	* config/i386/darwin.h: Define X86_CUSTOM_FUNCTION_TEST.
	* config/i386/i386.h: Define X86_CUSTOM_FUNCTION_TEST.
	* config/i386/i386.cc: Use X86_CUSTOM_FUNCTION_TEST.
2023-10-22 14:01:30 +01:00
Andrew Burgess
28d8c680aa core: Support heap-based trampolines
Generate heap-based nested function trampolines

Add support for allocating nested function trampolines on an
executable heap rather than on the stack. This is motivated by targets
such as AArch64 Darwin, which globally prohibit executing code on the
stack.

The target-specific routines for allocating and writing trampolines are
to be provided in libgcc.

The gcc flag -ftrampoline-impl controls whether to generate code
that instantiates trampolines on the stack, or to emit calls to
__builtin_nested_func_ptr_created and
__builtin_nested_func_ptr_deleted. Note that this flag is completely
independent of libgcc: If libgcc is for any reason missing those
symbols, you will get a link failure.

This implementation imposes some implicit restrictions as compared to
stack trampolines. longjmp'ing back to a state before a trampoline was
created will cause us to skip over the corresponding
__builtin_nested_func_ptr_deleted, which will leak trampolines
starting from the beginning of the linked list of allocated
trampolines. There may be scope for instrumenting longjmp/setjmp to
trigger cleanups of trampolines.

Co-Authored-By: Maxim Blinov <maxim.blinov@embecosm.com>
Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

gcc/ChangeLog:

	* builtins.def (BUILT_IN_NESTED_PTR_CREATED): Define.
	(BUILT_IN_NESTED_PTR_DELETED): Ditto.
	* common.opt (ftrampoline-impl): Add option to control
	generation of trampoline instantiation (heap or stack).
	* coretypes.h: Define enum trampoline_impl.
	* tree-nested.cc (convert_tramp_reference_op): Don't bother calling
	__builtin_adjust_trampoline for heap trampolines.
	(finalize_nesting_tree_1): Emit calls to
	__builtin_nested_...{created,deleted} if we're generating with
	-ftrampoline-impl=heap.
	* tree.cc (build_common_builtin_nodes): Build
	__builtin_nested_...{created,deleted}.
	* doc/invoke.texi (-ftrampoline-impl): Document.
2023-10-22 14:01:06 +01:00
Tsukasa OI
11f50716ee RISC-V: Prohibit combination of 'E' and 'H'
According to the ratified privileged specification (version 20211203),
it says:

> The hypervisor extension depends on an "I" base integer ISA with 32 x
> registers (RV32I or RV64I), not RV32E, which has only 16 x registers.

Also in the latest draft, it also prohibits RV64E with the 'H' extension.
This commit prohibits the combination of 'E' and 'H' extensions.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (riscv_subset_list::parse):
	Prohibit 'E' and 'H' combinations.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-26.c: New test.
2023-10-22 02:21:05 +00:00
Tsukasa OI
f232391ae6 RISC-V: 'Zfa' extension is now ratified
Since this extension is ratified, it now has the version number 1.0.

Reference:
<https://github.com/riscv/riscv-isa-manual/pull/1096>

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
	Change version number of the 'Zfa' extension to 1.0.
2023-10-22 02:21:05 +00:00
GCC Administrator
bc43a9e21c Daily bump. 2023-10-22 00:16:41 +00:00
Jonathan Wakely
405a4140fc libstdc++: Split std::basic_string::_M_use_local_data into two functions
This splits out the activate-the-union-member-for-constexpr logic from
_M_use_local_data, so that it can be used separately in cases that don't
need to use std::pointer_traits<pointer>::pointer_to to obtain the
return value.

This leaves only three uses of _M_use_local_data() which are all of the
same form:

  __s._M_data(_M_use_local_data());
  __s._M_set_length(0);

We could remove _M_use_local_data() and change those three places to use
a new _M_reset() function that does:

  _M_init_local_buf();
  _M_data(_M_local_data());
  _M_set_length(0);

This is left for a future change.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (_M_init_local_buf()): New
	function.
	(_M_use_local_data()): Use _M_init_local_buf.
	(basic_string(), basic_string(const Alloc&))
	(basic_string(basic_string&&))
	(basic_string(basic_string&&, const Alloc&)): Use
	_M_init_local_buf instead of _M_use_local_data().
	* include/bits/basic_string.tcc (swap(basic_string&))
	(_M_construct(InIter, InIter, input_iterator_tag))
	(_M_construct(InIter, InIter, forward_iterator_tag))
	(_M_construct(size_type, CharT), reserve()): Likewise.
2023-10-21 11:54:00 +01:00
Benjamin Brock
be34a8b538 libstdc++: Workaround for LLVM-61763 in <ranges>
This patch adds a small workaround that avoids declaring constrained
friends when compiling with Clang, instead making some members public.
MSVC's standard library has implemented a similar workaround.

Signed-off-by: Benjamin Brock <brock@cs.berkeley.edu>

libstdc++-v3/ChangeLog:

	* include/std/ranges (zip_view, adjacent_view): Implement
	workaround for LLVM-61763.
2023-10-21 11:54:00 +01:00
Dimitrij Mijoski
59a7d38997 libstdc++: testsuite: Enhance codecvt_unicode with tests for length()
We can test codecvt::length() with the same data that we test
codecvt::in(). For each call of in() we add another call to length().
Some additional small cosmentic changes are applied.

libstdc++-v3/ChangeLog:

	* testsuite/22_locale/codecvt/codecvt_unicode.h: Test length()
2023-10-21 11:54:00 +01:00
Jonathan Wakely
77209d43f1 libstdc++: Fix formatting of filesystem directory iterators
Fix indentation.

libstdc++-v3/ChangeLog:

	* include/bits/fs_dir.h (operator==(default_sentinel_t)): Fix
	indentation.
2023-10-21 11:54:00 +01:00