platform/upstream/gcc.git
16 months agoRISC-V: Implement ZKSH and ZKSED extensions
Liao Shihua [Mon, 20 Feb 2023 07:01:25 +0000 (15:01 +0800)]
RISC-V: Implement ZKSH and ZKSED extensions

This patch supports Zksh and Zksed extension.
It includes instruction's machine description and built-in funtions.

gcc/ChangeLog:

* config/riscv/crypto.md (riscv_sm3p0_<mode>): Add ZKSED's and ZKSH's
instructions.
(riscv_sm3p1_<mode>): New.
(riscv_sm4ed_<mode>): New.
(riscv_sm4ks_<mode>): New.
* config/riscv/riscv-builtins.cc (AVAIL): Add ZKSED's and ZKSH's AVAIL.
* config/riscv/riscv-scalar-crypto.def (RISCV_BUILTIN): Add ZKSED's and
ZKSH's built-in functions.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zksed32.c: New test.
* gcc.target/riscv/zksed64.c: New test.
* gcc.target/riscv/zksh32.c: New test.
* gcc.target/riscv/zksh64.c: New test.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
16 months agoRISC-V: Implement ZKNH extension
Liao Shihua [Mon, 20 Feb 2023 07:01:24 +0000 (15:01 +0800)]
RISC-V: Implement ZKNH extension

This patch supports Zknh extension.
It includes instruction's machine description and built-in funtions.

gcc/ChangeLog:

* config/riscv/crypto.md (riscv_sha256sig0_<mode>): Add ZKNH's instructions.
(riscv_sha256sig1_<mode>): New.
(riscv_sha256sum0_<mode>): New.
(riscv_sha256sum1_<mode>): New.
(riscv_sha512sig0h): New.
(riscv_sha512sig0l): New.
(riscv_sha512sig1h): New.
(riscv_sha512sig1l): New.
(riscv_sha512sum0r): New.
(riscv_sha512sum1r): New.
(riscv_sha512sig0): New.
(riscv_sha512sig1): New.
(riscv_sha512sum0): New.
(riscv_sha512sum1): New.
* config/riscv/riscv-builtins.cc (AVAIL): And ZKNH's AVAIL.
* config/riscv/riscv-scalar-crypto.def (RISCV_BUILTIN): And ZKNH's
built-in functions.
(DIRECT_BUILTIN): Add new.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zknh-sha256.c: New test.
* gcc.target/riscv/zknh-sha512-32.c: New test.
* gcc.target/riscv/zknh-sha512-64.c: New test.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
16 months agoRISC-V: Implement ZKND and ZKNE extensions
Liao Shihua [Mon, 20 Feb 2023 07:01:23 +0000 (15:01 +0800)]
RISC-V: Implement ZKND and ZKNE extensions

This patch supports Zkne and Zknd extension.
It includes instruction's machine description and built-in funtions.

gcc/ChangeLog:

* config/riscv/constraints.md (D03): Add constants of bs and rnum.
(DsA): New.
* config/riscv/crypto.md (riscv_aes32dsi): Add ZKND's and ZKNE's instructions.
(riscv_aes32dsmi): New.
(riscv_aes64ds): New.
(riscv_aes64dsm): New.
(riscv_aes64im): New.
(riscv_aes64ks1i): New.
(riscv_aes64ks2): New.
(riscv_aes32esi): New.
(riscv_aes32esmi): New.
(riscv_aes64es): New.
(riscv_aes64esm): New.
* config/riscv/riscv-builtins.cc (AVAIL): Add ZKND's and ZKNE's AVAIL.
* config/riscv/riscv-scalar-crypto.def (DIRECT_BUILTIN): Add ZKND's and
ZKNE's built-in functions.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zknd32.c: New test.
* gcc.target/riscv/zknd64.c: New test.
* gcc.target/riscv/zkne32.c: New test.
* gcc.target/riscv/zkne64.c: New test.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
16 months agoRISC-V: Implement ZBKB, ZBKC and ZBKX extensions
Liao Shihua [Mon, 20 Feb 2023 07:01:22 +0000 (15:01 +0800)]
RISC-V: Implement ZBKB, ZBKC and ZBKX extensions

This patch supports Zkbk, Zbkc and Zkbx extension.
It includes instruction's machine description and built-in funtions.
It is worth mentioning that this patch only adds instructions in Zbkb but no
longer in Zbb.
If any instructions both in Zbb and Zbkb, they will be generated by code
generator instead of built-in functions.

gcc/ChangeLog:

* config/riscv/bitmanip.md: Add ZBKB's instructions.
* config/riscv/riscv-builtins.cc (AVAIL): Add new.
* config/riscv/riscv.md: Add new type for crypto instructions.
* config/riscv/crypto.md: Add Scalar Cryptography extension's machine
description file.
* config/riscv/riscv-scalar-crypto.def: Add Scalar Cryptography
extension's built-in function file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zbkb32.c: New test.
* gcc.target/riscv/zbkb64.c: New test.
* gcc.target/riscv/zbkc32.c: New test.
* gcc.target/riscv/zbkc64.c: New test.
* gcc.target/riscv/zbkx32.c: New test.
* gcc.target/riscv/zbkx64.c: New test.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
16 months agoRISC-V: Add prototypes for RISC-V Crypto built-in functions
Liao Shihua [Mon, 20 Feb 2023 07:01:21 +0000 (15:01 +0800)]
RISC-V: Add prototypes for RISC-V Crypto built-in functions

This patch adds prototypes for RISC-V Crypto built-in functions.

gcc/ChangeLog:

* config/riscv/riscv-builtins.cc (RISCV_FTYPE_NAME2): New.
(RISCV_FTYPE_NAME3): New.
(RISCV_ATYPE_QI): New.
(RISCV_ATYPE_HI): New.
(RISCV_FTYPE_ATYPES2): New.
(RISCV_FTYPE_ATYPES3): New.
* config/riscv/riscv-ftypes.def (2): New.
(3): New.

Co-Authored-By: SiYu Wu <siyu@isrc.iscas.ac.cn>
16 months agoRISC-V: costs: miscomputed shiftadd_cost triggering synth_mult [PR/108987]
Vineet Gupta [Wed, 1 Mar 2023 19:53:15 +0000 (11:53 -0800)]
RISC-V: costs: miscomputed shiftadd_cost triggering synth_mult [PR/108987]

This showed up as dynamic icount regression in SPEC 531.deepsjeng with upstream
gcc (vs. gcc 12.2). gcc was resorting to synthetic multiply using shift+add(s)
even when multiply had clear cost benefit.

|00000000000133b8 <see(state_t*, int, int, int, int) [clone .constprop.0]+0x382>:
|   133b8: srl a3,a1,s6
|   133bc: and a3,a3,s5
|   133c0: slli a4,a3,0x9
|   133c4: add a4,a4,a3
|   133c6: slli a4,a4,0x9
|   133c8: add a4,a4,a3
|   133ca: slli a3,a4,0x1b
|   133ce: add a4,a4,a3

vs. gcc 12 doing something lke below.

|00000000000131c4 <see(state_t*, int, int, int, int) [clone .constprop.0]+0x35c>:
|   131c4: ld s1,8(sp)
|   131c6: srl a3,a1,s4
|   131ca: and a3,a3,s11
|   131ce: mul a3,a3,s1

Bisected this to f90cb39235c4 ("RISC-V: costs: support shift-and-add in
strength-reduction"). The intent was to optimize cost for
shift-add-pow2-{1,2,3} corresponding to bitmanip insns SH*ADD, but ended
up doing that for all shift values which seems to favor synthezing
multiply among others.

The bug itself is trivial, IN_RANGE() calling pow2p_hwi() which returns bool
vs. exact_log2() returning power of 2.

This fix also requires update to the test introduced by the same commit
which now generates MUL vs. synthesizing it.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_rtx_costs): Fixed IN_RANGE() to
use exact_log2().

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zba-shNadd-07.c: f2(i*783) now generates MUL vs.
5 insn sh1add+slli+add+slli+sub.
* gcc.target/riscv/pr108987.c: New test.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
16 months agoRISC-V: Add RVV misc intrinsic support
Ju-Zhe Zhong [Thu, 2 Mar 2023 08:01:52 +0000 (16:01 +0800)]
RISC-V: Add RVV misc intrinsic support

Co-authored-by: kito-cheng <kito.cheng@sifive.com>
gcc/ChangeLog:

* config/riscv/predicates.md (vector_any_register_operand): New predicate.
* config/riscv/riscv-c.cc (riscv_check_builtin_call): New function.
(riscv_register_pragmas): Add builtin function check call.
* config/riscv/riscv-protos.h (RVV_VUNDEF): Adapt macro.
(check_builtin_call): New function.
* config/riscv/riscv-vector-builtins-bases.cc (class vundefined): New class.
(class vreinterpret): Ditto.
(class vlmul_ext): Ditto.
(class vlmul_trunc): Ditto.
(class vset): Ditto.
(class vget): Ditto.
(BASE): Ditto.
* config/riscv/riscv-vector-builtins-bases.h: Ditto.
* config/riscv/riscv-vector-builtins-functions.def (vluxei8): Change name.
(vluxei16): Ditto.
(vluxei32): Ditto.
(vluxei64): Ditto.
(vloxei8): Ditto.
(vloxei16): Ditto.
(vloxei32): Ditto.
(vloxei64): Ditto.
(vsuxei8): Ditto.
(vsuxei16): Ditto.
(vsuxei32): Ditto.
(vsuxei64): Ditto.
(vsoxei8): Ditto.
(vsoxei16): Ditto.
(vsoxei32): Ditto.
(vsoxei64): Ditto.
(vundefined): Add new intrinsic.
(vreinterpret): Ditto.
(vlmul_ext): Ditto.
(vlmul_trunc): Ditto.
(vset): Ditto.
(vget): Ditto.
* config/riscv/riscv-vector-builtins-shapes.cc (struct return_mask_def): New class.
(struct narrow_alu_def): Ditto.
(struct reduc_alu_def): Ditto.
(struct vundefined_def): Ditto.
(struct misc_def): Ditto.
(struct vset_def): Ditto.
(struct vget_def): Ditto.
(SHAPE): Ditto.
* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_EEW8_INTERPRET_OPS): New def.
(DEF_RVV_EEW16_INTERPRET_OPS): Ditto.
(DEF_RVV_EEW32_INTERPRET_OPS): Ditto.
(DEF_RVV_EEW64_INTERPRET_OPS): Ditto.
(DEF_RVV_X2_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X4_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X8_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X16_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X32_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X64_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_LMUL1_OPS): Ditto.
(DEF_RVV_LMUL2_OPS): Ditto.
(DEF_RVV_LMUL4_OPS): Ditto.
(vint16mf4_t): Ditto.
(vint16mf2_t): Ditto.
(vint16m1_t): Ditto.
(vint16m2_t): Ditto.
(vint16m4_t): Ditto.
(vint16m8_t): Ditto.
(vint32mf2_t): Ditto.
(vint32m1_t): Ditto.
(vint32m2_t): Ditto.
(vint32m4_t): Ditto.
(vint32m8_t): Ditto.
(vint64m1_t): Ditto.
(vint64m2_t): Ditto.
(vint64m4_t): Ditto.
(vint64m8_t): Ditto.
(vuint16mf4_t): Ditto.
(vuint16mf2_t): Ditto.
(vuint16m1_t): Ditto.
(vuint16m2_t): Ditto.
(vuint16m4_t): Ditto.
(vuint16m8_t): Ditto.
(vuint32mf2_t): Ditto.
(vuint32m1_t): Ditto.
(vuint32m2_t): Ditto.
(vuint32m4_t): Ditto.
(vuint32m8_t): Ditto.
(vuint64m1_t): Ditto.
(vuint64m2_t): Ditto.
(vuint64m4_t): Ditto.
(vuint64m8_t): Ditto.
(vint8mf4_t): Ditto.
(vint8mf2_t): Ditto.
(vint8m1_t): Ditto.
(vint8m2_t): Ditto.
(vint8m4_t): Ditto.
(vint8m8_t): Ditto.
(vuint8mf4_t): Ditto.
(vuint8mf2_t): Ditto.
(vuint8m1_t): Ditto.
(vuint8m2_t): Ditto.
(vuint8m4_t): Ditto.
(vuint8m8_t): Ditto.
(vint8mf8_t): Ditto.
(vuint8mf8_t): Ditto.
(vfloat32mf2_t): Ditto.
(vfloat32m1_t): Ditto.
(vfloat32m2_t): Ditto.
(vfloat32m4_t): Ditto.
(vfloat64m1_t): Ditto.
(vfloat64m2_t): Ditto.
(vfloat64m4_t): Ditto.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_TYPE): Ditto.
(DEF_RVV_EEW8_INTERPRET_OPS): Ditto.
(DEF_RVV_EEW16_INTERPRET_OPS): Ditto.
(DEF_RVV_EEW32_INTERPRET_OPS): Ditto.
(DEF_RVV_EEW64_INTERPRET_OPS): Ditto.
(DEF_RVV_X2_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X4_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X8_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X16_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X32_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_X64_VLMUL_EXT_OPS): Ditto.
(DEF_RVV_LMUL1_OPS): Ditto.
(DEF_RVV_LMUL2_OPS): Ditto.
(DEF_RVV_LMUL4_OPS): Ditto.
(DEF_RVV_TYPE_INDEX): Ditto.
(required_extensions_p): Adapt for new intrinsic support/
(get_required_extensions): New function.
(check_required_extensions): Ditto.
(unsigned_base_type_p): Remove.
(rvv_arg_type_info::get_scalar_ptr_type): New function.
(get_mode_for_bitsize): Remove.
(rvv_arg_type_info::get_scalar_const_ptr_type): New function.
(rvv_arg_type_info::get_base_vector_type): Ditto.
(rvv_arg_type_info::get_function_type_index): Ditto.
(DEF_RVV_BASE_TYPE): New def.
(function_builder::apply_predication): New class.
(function_expander::mask_mode): Ditto.
(function_checker::function_checker): Ditto.
(function_checker::report_non_ice): Ditto.
(function_checker::report_out_of_range): Ditto.
(function_checker::require_immediate): Ditto.
(function_checker::require_immediate_range): Ditto.
(function_checker::check): Ditto.
(check_builtin_call): Ditto.
* config/riscv/riscv-vector-builtins.def (DEF_RVV_TYPE): New def.
(DEF_RVV_BASE_TYPE): Ditto.
(DEF_RVV_TYPE_INDEX): Ditto.
(vbool64_t): Ditto.
(vbool32_t): Ditto.
(vbool16_t): Ditto.
(vbool8_t): Ditto.
(vbool4_t): Ditto.
(vbool2_t): Ditto.
(vbool1_t): Ditto.
(vuint8mf8_t): Ditto.
(vuint8mf4_t): Ditto.
(vuint8mf2_t): Ditto.
(vuint8m1_t): Ditto.
(vuint8m2_t): Ditto.
(vint8m4_t): Ditto.
(vuint8m4_t): Ditto.
(vint8m8_t): Ditto.
(vuint8m8_t): Ditto.
(vint16mf4_t): Ditto.
(vuint16mf2_t): Ditto.
(vuint16m1_t): Ditto.
(vuint16m2_t): Ditto.
(vuint16m4_t): Ditto.
(vuint16m8_t): Ditto.
(vint32mf2_t): Ditto.
(vuint32m1_t): Ditto.
(vuint32m2_t): Ditto.
(vuint32m4_t): Ditto.
(vuint32m8_t): Ditto.
(vuint64m1_t): Ditto.
(vuint64m2_t): Ditto.
(vuint64m4_t): Ditto.
(vuint64m8_t): Ditto.
(vfloat32mf2_t): Ditto.
(vfloat32m1_t): Ditto.
(vfloat32m2_t): Ditto.
(vfloat32m4_t): Ditto.
(vfloat32m8_t): Ditto.
(vfloat64m1_t): Ditto.
(vfloat64m4_t): Ditto.
(vector): Move it def.
(scalar): Ditto.
(mask): Ditto.
(signed_vector): Ditto.
(unsigned_vector): Ditto.
(unsigned_scalar): Ditto.
(vector_ptr): Ditto.
(scalar_ptr): Ditto.
(scalar_const_ptr): Ditto.
(void): Ditto.
(size): Ditto.
(ptrdiff): Ditto.
(unsigned_long): Ditto.
(long): Ditto.
(eew8_index): Ditto.
(eew16_index): Ditto.
(eew32_index): Ditto.
(eew64_index): Ditto.
(shift_vector): Ditto.
(double_trunc_vector): Ditto.
(quad_trunc_vector): Ditto.
(oct_trunc_vector): Ditto.
(double_trunc_scalar): Ditto.
(double_trunc_signed_vector): Ditto.
(double_trunc_unsigned_vector): Ditto.
(double_trunc_unsigned_scalar): Ditto.
(double_trunc_float_vector): Ditto.
(float_vector): Ditto.
(lmul1_vector): Ditto.
(widen_lmul1_vector): Ditto.
(eew8_interpret): Ditto.
(eew16_interpret): Ditto.
(eew32_interpret): Ditto.
(eew64_interpret): Ditto.
(vlmul_ext_x2): Ditto.
(vlmul_ext_x4): Ditto.
(vlmul_ext_x8): Ditto.
(vlmul_ext_x16): Ditto.
(vlmul_ext_x32): Ditto.
(vlmul_ext_x64): Ditto.
* config/riscv/riscv-vector-builtins.h (DEF_RVV_BASE_TYPE): New def.
(struct function_type_info): New function.
(struct rvv_arg_type_info): Ditto.
(class function_checker): New class.
(rvv_arg_type_info::get_scalar_type): New function.
(rvv_arg_type_info::get_vector_type): Ditto.
(function_expander::ret_mode): New function.
(function_checker::arg_mode): Ditto.
(function_checker::ret_mode): Ditto.
* config/riscv/t-riscv: Add generator.
* config/riscv/vector-iterators.md: New iterators.
* config/riscv/vector.md (vundefined<mode>): New pattern.
(@vundefined<mode>): Ditto.
(@vreinterpret<mode>): Ditto.
(@vlmul_extx2<mode>): Ditto.
(@vlmul_extx4<mode>): Ditto.
(@vlmul_extx8<mode>): Ditto.
(@vlmul_extx16<mode>): Ditto.
(@vlmul_extx32<mode>): Ditto.
(@vlmul_extx64<mode>): Ditto.
(*vlmul_extx2<mode>): Ditto.
(*vlmul_extx4<mode>): Ditto.
(*vlmul_extx8<mode>): Ditto.
(*vlmul_extx16<mode>): Ditto.
(*vlmul_extx32<mode>): Ditto.
(*vlmul_extx64<mode>): Ditto.
* config/riscv/genrvv-type-indexer.cc: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/vlmul_v.c: New test.

Co-authored-by: kito-cheng <kito.cheng@sifive.com>
16 months agoRISC-V: Add permutation C/C++ support
Ju-Zhe Zhong [Mon, 27 Feb 2023 10:32:25 +0000 (18:32 +0800)]
RISC-V: Add permutation C/C++ support

gcc/ChangeLog:

* config/riscv/riscv-protos.h (enum vlen_enum): New enum.
(slide1_sew64_helper): New function.
* config/riscv/riscv-v.cc (compute_vlmax): Ditto.
(get_unknown_min_value): Ditto.
(force_vector_length_operand): Ditto.
(gen_no_side_effects_vsetvl_rtx): Ditto.
(get_vl_x2_rtx): Ditto.
(slide1_sew64_helper): Ditto.
* config/riscv/riscv-vector-builtins-bases.cc (class slideop): New class.
(class vrgather): Ditto.
(class vrgatherei16): Ditto.
(class vcompress): Ditto.
(BASE): Ditto.
* config/riscv/riscv-vector-builtins-bases.h: Ditto.
* config/riscv/riscv-vector-builtins-functions.def (vslideup): Ditto.
(vslidedown): Ditto.
(vslide1up): Ditto.
(vslide1down): Ditto.
(vfslide1up): Ditto.
(vfslide1down): Ditto.
(vrgather): Ditto.
(vrgatherei16): Ditto.
(vcompress): Ditto.
* config/riscv/riscv-vector-builtins-types.def (DEF_RVV_EI16_OPS): New macro.
(vint8mf8_t): Ditto.
(vint8mf4_t): Ditto.
(vint8mf2_t): Ditto.
(vint8m1_t): Ditto.
(vint8m2_t): Ditto.
(vint8m4_t): Ditto.
(vint16mf4_t): Ditto.
(vint16mf2_t): Ditto.
(vint16m1_t): Ditto.
(vint16m2_t): Ditto.
(vint16m4_t): Ditto.
(vint16m8_t): Ditto.
(vint32mf2_t): Ditto.
(vint32m1_t): Ditto.
(vint32m2_t): Ditto.
(vint32m4_t): Ditto.
(vint32m8_t): Ditto.
(vint64m1_t): Ditto.
(vint64m2_t): Ditto.
(vint64m4_t): Ditto.
(vint64m8_t): Ditto.
(vuint8mf8_t): Ditto.
(vuint8mf4_t): Ditto.
(vuint8mf2_t): Ditto.
(vuint8m1_t): Ditto.
(vuint8m2_t): Ditto.
(vuint8m4_t): Ditto.
(vuint16mf4_t): Ditto.
(vuint16mf2_t): Ditto.
(vuint16m1_t): Ditto.
(vuint16m2_t): Ditto.
(vuint16m4_t): Ditto.
(vuint16m8_t): Ditto.
(vuint32mf2_t): Ditto.
(vuint32m1_t): Ditto.
(vuint32m2_t): Ditto.
(vuint32m4_t): Ditto.
(vuint32m8_t): Ditto.
(vuint64m1_t): Ditto.
(vuint64m2_t): Ditto.
(vuint64m4_t): Ditto.
(vuint64m8_t): Ditto.
(vfloat32mf2_t): Ditto.
(vfloat32m1_t): Ditto.
(vfloat32m2_t): Ditto.
(vfloat32m4_t): Ditto.
(vfloat32m8_t): Ditto.
(vfloat64m1_t): Ditto.
(vfloat64m2_t): Ditto.
(vfloat64m4_t): Ditto.
(vfloat64m8_t): Ditto.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_EI16_OPS): Ditto.
* config/riscv/riscv.md: Adjust RVV instruction types.
* config/riscv/vector-iterators.md (down): New iterator.
(=vd,vr): New attribute.
(UNSPEC_VSLIDE1UP): New unspec.
* config/riscv/vector.md (@pred_slide<ud><mode>): New pattern.
(*pred_slide<ud><mode>): Ditto.
(*pred_slide<ud><mode>_extended): Ditto.
(@pred_gather<mode>): Ditto.
(@pred_gather<mode>_scalar): Ditto.
(@pred_gatherei16<mode>): Ditto.
(@pred_compress<mode>): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/binop_vx_constraint-167.c: New test.
* gcc.target/riscv/rvv/base/binop_vx_constraint-168.c: New test.
* gcc.target/riscv/rvv/base/binop_vx_constraint-169.c: New test.
* gcc.target/riscv/rvv/base/binop_vx_constraint-170.c: New test.
* gcc.target/riscv/rvv/base/binop_vx_constraint-171.c: New test.
* gcc.target/riscv/rvv/base/binop_vx_constraint-172.c: New test.
* gcc.target/riscv/rvv/base/binop_vx_constraint-173.c: New test.
* gcc.target/riscv/rvv/base/binop_vx_constraint-174.c: New test.

16 months agoRISC-V: Remove void_type_node of void_args for vsetvlmax intrinsic
Ju-Zhe Zhong [Mon, 27 Feb 2023 08:01:32 +0000 (16:01 +0800)]
RISC-V: Remove void_type_node of void_args for vsetvlmax intrinsic

This patch is to fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108927.
PR108927

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins.cc: Remove void_type_node.

16 months agoRISC-V: Add testcase for VSETVL PASS
Ju-Zhe Zhong [Fri, 24 Feb 2023 15:19:14 +0000 (23:19 +0800)]
RISC-V: Add testcase for VSETVL PASS

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/scalar_move-1.c: New test.
* gcc.target/riscv/rvv/base/scalar_move-2.c: New test.
* gcc.target/riscv/rvv/base/scalar_move-3.c: New test.
* gcc.target/riscv/rvv/base/scalar_move-4.c: New test.
* gcc.target/riscv/rvv/base/scalar_move-5.c: New test.
* gcc.target/riscv/rvv/base/scalar_move-6.c: New test.
* gcc.target/riscv/rvv/base/scalar_move-7.c: New test.
* gcc.target/riscv/rvv/base/scalar_move-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-100.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-101.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-78.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-79.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-80.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-81.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-82.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-83.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-84.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-85.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-86.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-87.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-88.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-89.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-90.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-91.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-92.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-93.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-94.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-95.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-96.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-97.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-98.c: New test.
* gcc.target/riscv/rvv/vsetvl/avl_single-99.c: New test.

16 months agoRISC-V: Add scalar move support and fix VSETVL bugs
Ju-Zhe Zhong [Fri, 24 Feb 2023 15:18:02 +0000 (23:18 +0800)]
RISC-V: Add scalar move support and fix VSETVL bugs

gcc/ChangeLog:

* config/riscv/constraints.md (Wb1): New constraint.
* config/riscv/predicates.md
(vector_least_significant_set_mask_operand): New predicate.
(vector_broadcast_mask_operand): Ditto.
* config/riscv/riscv-protos.h (enum vlmul_type): Adjust.
(gen_scalar_move_mask): New function.
* config/riscv/riscv-v.cc (gen_scalar_move_mask): Ditto.
* config/riscv/riscv-vector-builtins-bases.cc (class vmv): New class.
(class vmv_s): Ditto.
(BASE): Ditto.
* config/riscv/riscv-vector-builtins-bases.h: Ditto.
* config/riscv/riscv-vector-builtins-functions.def (vmv_x): Ditto.
(vmv_s): Ditto.
(vfmv_f): Ditto.
(vfmv_s): Ditto.
* config/riscv/riscv-vector-builtins-shapes.cc (struct scalar_move_def): Ditto.
(SHAPE): Ditto.
* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
* config/riscv/riscv-vector-builtins.cc (function_expander::mask_mode): Ditto.
(function_expander::use_exact_insn): New function.
(function_expander::use_contiguous_load_insn): New function.
(function_expander::use_contiguous_store_insn): New function.
(function_expander::use_ternop_insn): New function.
(function_expander::use_widen_ternop_insn): New function.
(function_expander::use_scalar_move_insn): New function.
* config/riscv/riscv-vector-builtins.def (s): New operand suffix.
* config/riscv/riscv-vector-builtins.h
(function_expander::add_scalar_move_mask_operand): New class.
* config/riscv/riscv-vsetvl.cc (ignore_vlmul_insn_p): New function.
(scalar_move_insn_p): Ditto.
(has_vsetvl_killed_avl_p): Ditto.
(anticipatable_occurrence_p): Ditto.
(insert_vsetvl): Ditto.
(get_vl_vtype_info): Ditto.
(calculate_sew): Ditto.
(calculate_vlmul): Ditto.
(incompatible_avl_p): Ditto.
(different_sew_p): Ditto.
(different_lmul_p): Ditto.
(different_ratio_p): Ditto.
(different_tail_policy_p): Ditto.
(different_mask_policy_p): Ditto.
(possible_zero_avl_p): Ditto.
(first_ratio_invalid_for_second_sew_p): Ditto.
(first_ratio_invalid_for_second_lmul_p): Ditto.
(second_ratio_invalid_for_first_sew_p): Ditto.
(second_ratio_invalid_for_first_lmul_p): Ditto.
(second_sew_less_than_first_sew_p): Ditto.
(first_sew_less_than_second_sew_p): Ditto.
(compare_lmul): Ditto.
(second_lmul_less_than_first_lmul_p): Ditto.
(first_lmul_less_than_second_lmul_p): Ditto.
(first_ratio_less_than_second_ratio_p): Ditto.
(second_ratio_less_than_first_ratio_p): Ditto.
(DEF_INCOMPATIBLE_COND): Ditto.
(greatest_sew): Ditto.
(first_sew): Ditto.
(second_sew): Ditto.
(first_vlmul): Ditto.
(second_vlmul): Ditto.
(first_ratio): Ditto.
(second_ratio): Ditto.
(vlmul_for_first_sew_second_ratio): Ditto.
(ratio_for_second_sew_first_vlmul): Ditto.
(DEF_SEW_LMUL_FUSE_RULE): Ditto.
(always_unavailable): Ditto.
(avl_unavailable_p): Ditto.
(sew_unavailable_p): Ditto.
(lmul_unavailable_p): Ditto.
(ge_sew_unavailable_p): Ditto.
(ge_sew_lmul_unavailable_p): Ditto.
(ge_sew_ratio_unavailable_p): Ditto.
(DEF_UNAVAILABLE_COND): Ditto.
(same_sew_lmul_demand_p): Ditto.
(propagate_avl_across_demands_p): Ditto.
(reg_available_p): Ditto.
(avl_info::has_non_zero_avl): Ditto.
(vl_vtype_info::has_non_zero_avl): Ditto.
(vector_insn_info::operator>=): Refactor.
(vector_insn_info::parse_insn): Adjust for scalar move.
(vector_insn_info::demand_vl_vtype): Remove.
(vector_insn_info::compatible_p): New function.
(vector_insn_info::compatible_avl_p): Ditto.
(vector_insn_info::compatible_vtype_p): Ditto.
(vector_insn_info::available_p): Ditto.
(vector_insn_info::merge): Ditto.
(vector_insn_info::fuse_avl): Ditto.
(vector_insn_info::fuse_sew_lmul): Ditto.
(vector_insn_info::fuse_tail_policy): Ditto.
(vector_insn_info::fuse_mask_policy): Ditto.
(vector_insn_info::dump): Ditto.
(vector_infos_manager::release): Ditto.
(pass_vsetvl::compute_local_backward_infos): Adjust for scalar move support.
(pass_vsetvl::get_backward_fusion_type): Adjust for scalar move support.
(pass_vsetvl::hard_empty_block_p): Ditto.
(pass_vsetvl::backward_demand_fusion): Ditto.
(pass_vsetvl::forward_demand_fusion): Ditto.
(pass_vsetvl::refine_vsetvls): Ditto.
(pass_vsetvl::cleanup_vsetvls): Ditto.
(pass_vsetvl::commit_vsetvls): Ditto.
(pass_vsetvl::propagate_avl): Ditto.
* config/riscv/riscv-vsetvl.h (enum demand_status): New class.
(struct demands_pair): Ditto.
(struct demands_cond): Ditto.
(struct demands_fuse_rule): Ditto.
* config/riscv/vector-iterators.md: New iterator.
* config/riscv/vector.md (@pred_broadcast<mode>): New pattern.
(*pred_broadcast<mode>): Ditto.
(*pred_broadcast<mode>_extended_scalar): Ditto.
(@pred_extract_first<mode>): Ditto.
(*pred_extract_first<mode>): Ditto.
(@pred_extract_first_trunc<mode>): Ditto.
* config/riscv/riscv-vsetvl.def: New file.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/vsetvlmax-10.c: Adjust test.
* gcc.target/riscv/rvv/vsetvl/vsetvlmax-11.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvlmax-12.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvlmax-15.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvlmax-18.c: Ditto.
* gcc.target/riscv/rvv/vsetvl/vsetvlmax-9.c: Ditto.

16 months agoRISC-V: Allow const0_rtx operand in max/min
Lin Sinan [Sun, 5 Mar 2023 08:09:50 +0000 (16:09 +0800)]
RISC-V: Allow const0_rtx operand in max/min

Optimize cases that use max[u]/min[u] against a zero constant.

E.g., the case int f(int x) { return x >= 0 ? x : 0; }
the current asm output in rv64gc_zba_zbb

 li rtmp,0
 max a0,a0,rtmp

could be optimized into

 max a0,a0,zero

gcc/ChangeLog:
* config/riscv/bitmanip.md: allow 0 constant in max/min
pattern.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbb-min-max-03.c: New test.

16 months agoRISC-V: Fix wrong partial subreg check for bsetidisi
Lin Sinan [Tue, 28 Feb 2023 05:00:36 +0000 (13:00 +0800)]
RISC-V: Fix wrong partial subreg check for bsetidisi

The partial subreg check should be for subreg operand(operand 1) instead of
the immediate operand(operand 2). This change also fix pr68648.c in zbs.

gcc/ChangeLog:

* config/riscv/bitmanip.md: Fix wrong index in the check.
Reviewed-by: <philipp.tomsich@vrull.eu>
16 months agoDaily bump.
GCC Administrator [Sun, 5 Mar 2023 00:16:49 +0000 (00:16 +0000)]
Daily bump.

16 months agoFix modula-2 rename autogenerated .c files to .cc
Gaius Mulley [Sat, 4 Mar 2023 13:11:05 +0000 (13:11 +0000)]
Fix modula-2 rename autogenerated .c files to .cc

This patch adds the replacement .cc files for the
autogenerated tools.

gcc/m2/ChangeLog:

* mc-boot-ch/GBuiltins.cc: New file.
* mc-boot-ch/Gdtoa.cc: New file.
* mc-boot-ch/Gerrno.cc: New file.
* mc-boot-ch/Gldtoa.cc: New file.
* mc-boot-ch/Gm2rtsdummy.cc: New file.
* mc-boot/GASCII.cc: New file.
* mc-boot/GArgs.cc: New file.
* mc-boot/GAssertion.cc: New file.
* mc-boot/GBreak.cc: New file.
* mc-boot/GCmdArgs.cc: New file.
* mc-boot/GDebug.cc: New file.
* mc-boot/GDynamicStrings.cc: New file.
* mc-boot/GEnvironment.cc: New file.
* mc-boot/GFIO.cc: New file.
* mc-boot/GFormatStrings.cc: New file.
* mc-boot/GFpuIO.cc: New file.
* mc-boot/GIO.cc: New file.
* mc-boot/GIndexing.cc: New file.
* mc-boot/GM2Dependent.cc: New file.
* mc-boot/GM2EXCEPTION.cc: New file.
* mc-boot/GM2RTS.cc: New file.
* mc-boot/GMemUtils.cc: New file.
* mc-boot/GNumberIO.cc: New file.
* mc-boot/GPushBackInput.cc: New file.
* mc-boot/GRTExceptions.cc: New file.
* mc-boot/GRTint.cc: New file.
* mc-boot/GSArgs.cc: New file.
* mc-boot/GSFIO.cc: New file.
* mc-boot/GStdIO.cc: New file.
* mc-boot/GStorage.cc: New file.
* mc-boot/GStrCase.cc: New file.
* mc-boot/GStrIO.cc: New file.
* mc-boot/GStrLib.cc: New file.
* mc-boot/GStringConvert.cc: New file.
* mc-boot/GSysStorage.cc: New file.
* mc-boot/GTimeString.cc: New file.
* mc-boot/Galists.cc: New file.
* mc-boot/Gdecl.cc: New file.
* mc-boot/Gkeyc.cc: New file.
* mc-boot/Glists.cc: New file.
* mc-boot/GmcComment.cc: New file.
* mc-boot/GmcComp.cc: New file.
* mc-boot/GmcDebug.cc: New file.
* mc-boot/GmcError.cc: New file.
* mc-boot/GmcFileName.cc: New file.
* mc-boot/GmcLexBuf.cc: New file.
* mc-boot/GmcMetaError.cc: New file.
* mc-boot/GmcOptions.cc: New file.
* mc-boot/GmcPreprocess.cc: New file.
* mc-boot/GmcPretty.cc: New file.
* mc-boot/GmcPrintf.cc: New file.
* mc-boot/GmcQuiet.cc: New file.
* mc-boot/GmcReserved.cc: New file.
* mc-boot/GmcSearch.cc: New file.
* mc-boot/GmcStack.cc: New file.
* mc-boot/GmcStream.cc: New file.
* mc-boot/Gmcp1.cc: New file.
* mc-boot/Gmcp2.cc: New file.
* mc-boot/Gmcp3.cc: New file.
* mc-boot/Gmcp4.cc: New file.
* mc-boot/Gmcp5.cc: New file.
* mc-boot/GnameKey.cc: New file.
* mc-boot/GsymbolKey.cc: New file.
* mc-boot/Gtop.cc: New file.
* mc-boot/Gvarargs.cc: New file.
* mc-boot/Gwlists.cc: New file.
* pge-boot/GASCII.cc: New file.
* pge-boot/GArgs.cc: New file.
* pge-boot/GAssertion.cc: New file.
* pge-boot/GBuiltins.cc: New file.
* pge-boot/GDebug.cc: New file.
* pge-boot/GDynamicStrings.cc: New file.
* pge-boot/GFIO.cc: New file.
* pge-boot/GIO.cc: New file.
* pge-boot/GIndexing.cc: New file.
* pge-boot/GLists.cc: New file.
* pge-boot/GM2Dependent.cc: New file.
* pge-boot/GM2EXCEPTION.cc: New file.
* pge-boot/GM2LINK.cc: New file.
* pge-boot/GM2RTS.cc: New file.
* pge-boot/GNameKey.cc: New file.
* pge-boot/GNumberIO.cc: New file.
* pge-boot/GOutput.cc: New file.
* pge-boot/GPushBackInput.cc: New file.
* pge-boot/GRTExceptions.cc: New file.
* pge-boot/GRTco.cc: New file.
* pge-boot/GSFIO.cc: New file.
* pge-boot/GSYSTEM.cc: New file.
* pge-boot/GSelective.cc: New file.
* pge-boot/GStdIO.cc: New file.
* pge-boot/GStorage.cc: New file.
* pge-boot/GStrCase.cc: New file.
* pge-boot/GStrIO.cc: New file.
* pge-boot/GStrLib.cc: New file.
* pge-boot/GSymbolKey.cc: New file.
* pge-boot/GSysExceptions.cc: New file.
* pge-boot/GSysStorage.cc: New file.
* pge-boot/Gabort.cc: New file.
* pge-boot/Gbnflex.cc: New file.
* pge-boot/Gcbuiltin.cc: New file.
* pge-boot/Gdtoa.cc: New file.
* pge-boot/Gerrno.cc: New file.
* pge-boot/Gldtoa.cc: New file.
* pge-boot/Glibc.cc: New file.
* pge-boot/Glibm.cc: New file.
* pge-boot/Gmcrts.cc: New file.
* pge-boot/Gpge.cc: New file.
* pge-boot/Gwrapc.cc: New file.
* pge-boot/main.cc: New file.
* pge-boot/network.cc: New file.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
16 months agoModula-2 rename autogenerated .c files to .cc
Gaius Mulley [Sat, 4 Mar 2023 12:44:49 +0000 (12:44 +0000)]
Modula-2 rename autogenerated .c files to .cc

This patch renames all the pge-boot/*.c files to .cc.  It also renames
the m2/mc-boot/*.c files to .cc.  Finally it renames some of the
mc-boot-ch hand built interface files to .cc.

gcc/m2/ChangeLog:

* Make-lang.in (MC-LIB-BOOT-C): Rename to MC-LIB-BOOT-CC.
(MC-BOOT-C): Rename to MC-BOOT-CC.
(BUILD-MC-BOOT-C): Rename to BUILD-MC-BOOT-CC.
(BUILD-MC-BOOT-AUTO-C): Rename to BUILD-MC-BOOT-AUTO-CC.
(m2/mc-boot/$(SRC_PREFIX)%.o): Change source file extension to .cc.
(m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto.
* Make-maintainer.in (m2/gm2-ppg-boot/$(SRC_PREFIX)%.o): Change
source file extension to .cc.
(m2/gm2-ppg-boot/main.o): Ditto.
(m2/gm2-ppg-boot/$(SRC_PREFIX)%.o): Ditto.
to .cc.
(m2/gm2-pg-boot/main.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)ldtoa.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)dtoa.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)errno.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)M2RTS.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)%.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)%.o): Ditto.
(m2/gm2-pge-boot/$(SRC_PREFIX)pge.o): Ditto.
(m2/gm2-pge-boot/main.o): Ditto.
(mc-push): Ditto.
(mc-clean): Ditto.
(mc-stage2): Ditto.
((objdir)/m2/mc-boot-gen): Ditto.
(m2/mc-boot-gen/$(SRC_PREFIX)decl.c): Ditto.
(m2/mc-boot-gen/$(SRC_PREFIX)%.c): Ditto.
* mc-boot-ch/GBuiltins.c: Correct comment and rename.
* mc-boot-ch/Gdtoa.c: Correct comment and rename.
* mc-boot-ch/Gldtoa.c: Correct comment and rename
* mc-boot-ch/Gtermios.cc: Rename from Gtermios.c.
* mc-boot-ch/Gerrno.c: Rename.
* mc-boot-ch/GRTco.c: Removed.
* mc-boot/GASCII.c: Rename to mc-boot/GASCII.cc.
* mc-boot/GArgs.c: Rename to mc-boot/GArgs.cc.
* mc-boot/GAssertion.c: Rename to mc-boot/GAssertion.cc.
* mc-boot/GBreak.c: Rename to mc-boot/GBreak.cc.
* mc-boot/GCmdArgs.c: Rename to mc-boot/GCmdArgs.cc.
* mc-boot/GDebug.c: Rename to mc-boot/GDebug.cc.
* mc-boot/GDynamicStrings.c: Rename to mc-boot/GDynamicStrings.cc.
* mc-boot/GEnvironment.c: Rename to mc-boot/GEnvironment.cc.
* mc-boot/GFIO.c: Rename to mc-boot/GFIO.cc.
* mc-boot/GFormatStrings.c: Rename to mc-boot/GFormatStrings.cc.
* mc-boot/GFpuIO.c: Rename to mc-boot/GFpuIO.cc.
* mc-boot/GIO.c: Rename to mc-boot/GIO.cc.
* mc-boot/GIndexing.c: Rename to mc-boot/GIndexing.cc.
* mc-boot/GM2Dependent.c: Rename to mc-boot/GM2Dependent.cc.
* mc-boot/GM2EXCEPTION.c: Rename to mc-boot/GM2EXCEPTION.cc.
* mc-boot/GM2RTS.c: Rename to mc-boot/GM2RTS.cc.
* mc-boot/GMemUtils.c: Rename to mc-boot/GMemUtils.cc.
* mc-boot/GNumberIO.c: Rename to mc-boot/GNumberIO.cc.
* mc-boot/GPushBackInput.c: Rename to mc-boot/GPushBackInput.cc.
* mc-boot/GRTExceptions.c: Rename to mc-boot/GRTExceptions.cc.
* mc-boot/GRTint.c: Rename to mc-boot/GRTint.cc.
* mc-boot/GSArgs.c: Rename to mc-boot/GSArgs.cc.
* mc-boot/GSFIO.c: Rename to mc-boot/GSFIO.cc.
* mc-boot/GStdIO.c: Rename to mc-boot/GStdIO.cc.
* mc-boot/GStorage.c: Rename to mc-boot/GStorage.cc.
* mc-boot/GStrCase.c: Rename to mc-boot/GStrCase.cc.
* mc-boot/GStrIO.c: Rename to mc-boot/GStrIO.cc.
* mc-boot/GStrLib.c: Rename to mc-boot/GStrLib.cc.
* mc-boot/GStringConvert.c: Rename to mc-boot/GStringConvert.cc.
* mc-boot/GSysStorage.c: Rename to mc-boot/GSysStorage.cc.
* mc-boot/GTimeString.c: Rename to mc-boot/GTimeString.cc.
* mc-boot/Galists.c: Rename to mc-boot/Galists.cc.
* mc-boot/Gdecl.c: Rename to mc-boot/Gdecl.cc.
* mc-boot/Gkeyc.c: Rename to mc-boot/Gkeyc.cc.
* mc-boot/Glists.c: Rename to mc-boot/Glists.cc.
* mc-boot/GmcComment.c: Rename to mc-boot/GmcComment.cc.
* mc-boot/GmcComp.c: Rename to mc-boot/GmcComp.cc.
* mc-boot/GmcDebug.c: Rename to mc-boot/GmcDebug.cc.
* mc-boot/GmcError.c: Rename to mc-boot/GmcError.cc.
* mc-boot/GmcFileName.c: Rename to mc-boot/GmcFileName.cc.
* mc-boot/GmcLexBuf.c: Rename to mc-boot/GmcLexBuf.cc.
* mc-boot/GmcMetaError.c: Rename to mc-boot/GmcMetaError.cc.
* mc-boot/GmcOptions.c: Rename to mc-boot/GmcOptions.cc.
* mc-boot/GmcPreprocess.c: Rename to mc-boot/GmcPreprocess.cc.
* mc-boot/GmcPretty.c: Rename to mc-boot/GmcPretty.cc.
* mc-boot/GmcPrintf.c: Rename to mc-boot/GmcPrintf.cc.
* mc-boot/GmcQuiet.c: Rename to mc-boot/GmcQuiet.cc.
* mc-boot/GmcReserved.c: Rename to mc-boot/GmcReserved.cc.
* mc-boot/GmcSearch.c: Rename to mc-boot/GmcSearch.cc.
* mc-boot/GmcStack.c: Rename to mc-boot/GmcStack.cc.
* mc-boot/GmcStream.c: Rename to mc-boot/GmcStream.cc.
* mc-boot/Gmcp1.c: Rename to mc-boot/Gmcp1.cc.
* mc-boot/Gmcp2.c: Rename to mc-boot/Gmcp2.cc.
* mc-boot/Gmcp3.c: Rename to mc-boot/Gmcp3.cc.
* mc-boot/Gmcp4.c: Rename to mc-boot/Gmcp4.cc.
* mc-boot/Gmcp5.c: Rename to mc-boot/Gmcp5.cc.
* mc-boot/GnameKey.c: Rename to mc-boot/GnameKey.cc.
* mc-boot/GsymbolKey.c: Rename to mc-boot/GsymbolKey.cc.
* mc-boot/Gtop.c: Rename to mc-boot/Gtop.cc.
* mc-boot/Gvarargs.c: Rename to mc-boot/Gvarargs.cc.
* mc-boot/Gwlists.c: Rename to mc-boot/Gwlists.cc.
* pge-boot/GASCII.c: Rename to pge-boot/GASCII.cc.
* pge-boot/GArgs.c: Rename to pge-boot/GArgs.cc.
* pge-boot/GAssertion.c: Rename to pge-boot/GAssertion.cc.
* pge-boot/GBuiltins.c: Rename to pge-boot/GBuiltins.cc.
* pge-boot/GDebug.c: Rename to pge-boot/GDebug.cc.
* pge-boot/GDynamicStrings.c: Rename to pge-boot/GDynamicStrings.cc.
* pge-boot/GFIO.c: Rename to pge-boot/GFIO.cc.
* pge-boot/GIO.c: Rename to pge-boot/GIO.cc.
* pge-boot/GIndexing.c: Rename to pge-boot/GIndexing.cc.
* pge-boot/GLists.c: Rename to pge-boot/GLists.cc.
* pge-boot/GM2Dependent.c: Rename to pge-boot/GM2Dependent.cc.
* pge-boot/GM2EXCEPTION.c: Rename to pge-boot/GM2EXCEPTION.cc.
* pge-boot/GM2LINK.c: Rename to pge-boot/GM2LINK.cc.
* pge-boot/GM2RTS.c: Rename to pge-boot/GM2RTS.cc.
* pge-boot/GNameKey.c: Rename to pge-boot/GNameKey.cc.
* pge-boot/GNumberIO.c: Rename to pge-boot/GNumberIO.cc.
* pge-boot/GOutput.c: Rename to pge-boot/GOutput.cc.
* pge-boot/GPushBackInput.c: Rename to pge-boot/GPushBackInput.cc.
* pge-boot/GRTExceptions.c: Rename to pge-boot/GRTExceptions.cc.
* pge-boot/GRTco.c: Rename to pge-boot/GRTco.cc.
* pge-boot/GSFIO.c: Rename to pge-boot/GSFIO.cc.
* pge-boot/GSYSTEM.c: Rename to pge-boot/GSYSTEM.cc.
* pge-boot/GSelective.c: Rename to pge-boot/GSelective.cc.
* pge-boot/GStdIO.c: Rename to pge-boot/GStdIO.cc.
* pge-boot/GStorage.c: Rename to pge-boot/GStorage.cc.
* pge-boot/GStrCase.c: Rename to pge-boot/GStrCase.cc.
* pge-boot/GStrIO.c: Rename to pge-boot/GStrIO.cc.
* pge-boot/GStrLib.c: Rename to pge-boot/GStrLib.cc.
* pge-boot/GSymbolKey.c: Rename to pge-boot/GSymbolKey.cc.
* pge-boot/GSysExceptions.c: Rename to pge-boot/GSysExceptions.cc.
* pge-boot/GSysStorage.c: Rename to pge-boot/GSysStorage.cc.
* pge-boot/Gabort.c: Rename to pge-boot/Gabort.cc.
* pge-boot/Gbnflex.c: Rename to pge-boot/Gbnflex.cc.
* pge-boot/Gcbuiltin.c: Rename to pge-boot/Gcbuiltin.cc.
* pge-boot/Gdtoa.c: Rename to pge-boot/Gdtoa.cc.
* pge-boot/Gerrno.c: Rename to pge-boot/Gerrno.cc.
* pge-boot/Gldtoa.c: Rename to pge-boot/Gldtoa.cc.
* pge-boot/Glibc.c: Rename to pge-boot/Glibc.cc.
* pge-boot/Glibm.c: Rename to pge-boot/Glibm.cc.
* pge-boot/Gmcrts.c: Rename to pge-boot/Gmcrts.cc.
* pge-boot/Gpge.c: Rename to pge-boot/Gpge.cc.
* pge-boot/Gwrapc.c: Rename to pge-boot/Gwrapc.cc.
* pge-boot/README: Correct description.
* pge-boot/main.c: Rename to pge-boot/main.cc.
* pge-boot/network.c: Rename to pge-boot/network.cc.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
16 months agoRemove remaining traces of m_vecdata from comments [PR109006]
Jakub Jelinek [Sat, 4 Mar 2023 10:24:04 +0000 (11:24 +0100)]
Remove remaining traces of m_vecdata from comments [PR109006]

The following patch adjusts remaining references to the removed m_vecdata
array from vec.h in various comments.

2023-03-04  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/109006
* vec.cc (test_auto_alias): Adjust comment for removal of
m_vecdata.
* read-rtl-function.cc (function_reader::parse_block): Likewise.
* gdbhooks.py: Likewise.

16 months agotestsuite: Fix up syntax errors in scan-tree-dump-times target selectors
Jakub Jelinek [Sat, 4 Mar 2023 09:42:17 +0000 (10:42 +0100)]
testsuite: Fix up syntax errors in scan-tree-dump-times target selectors

On Thu, Mar 02, 2023 at 07:23:32PM +0100, Robin Dapp via Gcc-patches wrote:
> this patch changes SLP test expectations.  As we only vectorize when no
> more than one rgroup is present, no vectorization is performed.

This broke the tests, I'm seeing syntax errors:
ERROR: gcc.dg/vect/slp-3.c -flto -ffat-lto-objects: error executing dg-final: syntax error in target selector "target !  vect_partial_vectors || vect32  || s390_vx"
ERROR: gcc.dg/vect/slp-3.c: error executing dg-final: syntax error in target selector "target !  vect_partial_vectors || vect32  || s390_vx"
ERROR: gcc.dg/vect/slp-multitypes-11.c -flto -ffat-lto-objects: error executing dg-final: syntax error in target selector "target vect_unpack && vect_partial_vectors_usage_1 &&  ! s390_vx"
ERROR: gcc.dg/vect/slp-multitypes-11.c: error executing dg-final: syntax error in target selector "target vect_unpack && vect_partial_vectors_usage_1 &&  ! s390_vx"

The following patch fixes those.

2023-03-04  Jakub Jelinek  <jakub@redhat.com>

* gcc.dg/vect/slp-3.c: Fix up syntax errors in scan-tree-dump-times
target selectors.
* gcc.dg/vect/slp-multitypes-11.c: Likewise.

16 months agoc-family: Incremental fix for -Wsign-compare BIT_NOT_EXPR handling [PR107465]
Jakub Jelinek [Sat, 4 Mar 2023 09:21:45 +0000 (10:21 +0100)]
c-family: Incremental fix for -Wsign-compare BIT_NOT_EXPR handling [PR107465]

There can be too many extensions and seems I didn't get everything right in
the previously posted patch.

The following incremental patch ought to fix that.
The code can deal with quite a few sign/zero extensions at various spots
and it is important to deal with all of them right.
On the argument that contains BIT_NOT_EXPR we have:
MSB bits#4 bits#3 BIT_NOT_EXPR bits#2 bits#1 LSB
where bits#1 is one or more bits (TYPE_PRECISION (TREE_TYPE (arg0))
at the end of the function) we don't know anything about, for the purposes
of this warning it is VARYING that is inverted with BIT_NOT_EXPR to some other
VARYING bits;
bits#2 is one or more bits (TYPE_PRECISION (TREE_TYPE (op0)) -
TYPE_PRECISION (TREE_TYPE (arg0)) at the end of the function)
which are known to be 0 before the BIT_NOT_EXPR and 1 after it.
bits#3 is zero or more bits from the TYPE_PRECISION (TREE_TYPE (op0))
at the end of function to the TYPE_PRECISION (TREE_TYPE (op0)) at the
end of the function to TYPE_PRECISION (TREE_TYPE (op0)) at the start
of the function, which are either zero extension or sign extension.
And bits#4 is zero or more bits from the TYPE_PRECISION (TREE_TYPE (op0))
at the start of the function to TYPE_PRECISION (result_type), which
again can be zero or sign extension.

Now, vanilla trunk as well as the previously posted patch mishandles the
case where bits#3 are sign extended (as bits#2 are known to be all set,
that means bits#3 are all set too) but bits#4 are zero extended and are
thus all 0.

The patch fixes it by tracking the lowest bit which is known to be clear
above the known to be set bits (if any, otherwise it is precision of
result_type).

2023-03-04  Jakub Jelinek  <jakub@redhat.com>

PR c/107465
* c-warn.cc (warn_for_sign_compare): Don't warn for unset bits
above innermost zero extension of BIT_NOT_EXPR result.

* c-c++-common/Wsign-compare-2.c (f18): New test.

16 months agoc-family: Fix up -Wsign-compare BIT_NOT_EXPR handling [PR107465]
Jakub Jelinek [Sat, 4 Mar 2023 09:18:37 +0000 (10:18 +0100)]
c-family: Fix up -Wsign-compare BIT_NOT_EXPR handling [PR107465]

The following patch fixes multiple bugs in warn_for_sign_compare related to
the BIT_NOT_EXPR related warnings.
My understanding is that what those 3 warnings are meant to warn (since 1995
apparently) is the case where we have BIT_NOT_EXPR of a zero-extended
value, so in result_type the value is something like:
0b11111111XXXXXXXX (e.g. ~ of a 8->16 bit zero extension)
0b000000000000000011111111XXXXXXXX (e.g. ~ of a 8->16 bit zero extension
then zero extended to 32 bits)
0b111111111111111111111111XXXXXXXX (e.g. ~ of a 8->16 bit zero extension
then sign extended to 32 bits)
and the intention of the warning is to warn when this is compared against
something that has some 0 bits at the place where the above has guaranteed
1 bits, either ensured through comparison against constant where we know
the bits exactly, or through zero extension from some narrower type where
again we know at least some upper bits are zero extended.
The bugs in the warning code are:
1) misunderstanding of the {,c_common_}get_narrower APIs - the unsignedp
   it sets is only meaningful if the function actually returns something
   narrower (in that case it says whether the narrower value is then
   sign (0) or zero (1) extended to the originally passed value.
   Though op0 or op1 at this point might be already narrower than
   result_type, and if the function doesn't return anything narrower,
   it all depends on whether the passed in op{0,1} had TYPE_UNSIGNED
   type or not
2) the code didn't check at all whether the BIT_NOT_EXPR operand
   was actually zero extended (i.e. that it was narrower and unsignedp
   was set to 1 for it), all it did is check that unsignedp from the
   call was 1.  But that isn't well defined thing, if the argument
   is returned as is, the function sets unsignedp to 0, but if there
   is e.g. a useless cast to the same or compatible type in between,
   it can return 1 if the cast is unsigned; now, if BIT_NOT_EXPR
   operand is not zero extended, we know nothing at all about any bits
   in the operand containing BIT_NOT_EXPR, so there is nothing to warn
   about
3) the code was actually testing both operands after calling
   c_common_get_narrower on them and on the one with BIT_NOT_EXPR
   again for constants; I think that is just wrong in case the BIT_NOT_EXPR
   operand wouldn't be fully folded, the warning makes sense only if the
   other operand not having BIT_NOT_EXPR in it is constant
4) as can be seen from the above bit pattern examples, the upper bits above
   (in the patch arg0) aren't always all 1s, there could be some zero extension
   above it and from it one would have 0s, so that needs to be taken into
   account for the choice which constant bits to test for being always set
   otherwise warning is emitted, or for the zero extension guaranteed zero
   bits
5) the patch also simplifies the handling, we only do it if one but not
   both operands are BIT_NOT_EXPR after first {,c_common_}get_narrower,
   so we can just use std::swap to ensure it is the first one
6) the code compared bits against HOST_BITS_PER_LONG, which made sense
   back in 1995 when the values were stored into long, but now that they
   are HOST_WIDE_INT should test HOST_BITS_PER_WIDE_INT (or we could rewrite
   the stuff to wide_int, not done in the patch)

2023-03-04  Jakub Jelinek  <jakub@redhat.com>

PR c/107465
* c-warn.cc (warn_for_sign_compare): If c_common_get_narrower
doesn't return a narrower result, use TYPE_UNSIGNED to set unsignedp0
and unsignedp1.  For the one BIT_NOT_EXPR case vs. one without,
only check for constant in the non-BIT_NOT_EXPR operand, use std::swap
to simplify the code, only warn if BIT_NOT_EXPR operand is extended
from narrower unsigned, fix up computation of mask for the constant
cases and for unsigned other operand case handle differently
BIT_NOT_EXPR result being sign vs. zero extended.

* c-c++-common/Wsign-compare-2.c: New test.
* c-c++-common/pr107465.c: New test.

16 months agoc-family: Account for integral promotions of left shifts for -Wshift-overflow warning...
Jakub Jelinek [Sat, 4 Mar 2023 09:14:33 +0000 (10:14 +0100)]
c-family: Account for integral promotions of left shifts for -Wshift-overflow warning [PR107846]

The r13-1100-gacb1e6f43dc2bbedd124 change added match.pd narrowing
of left shifts, and while I believe the C++ FE calls the warning on unfolded
trees, the C FE folds them and so left shifts where integral promotion
happened and so were done in int type will be usually narrowed back to
char/signed char/unsigned char/short/unsigned short left shifts if the
shift count is constant and fits into the precision of the var being
shifted.
One possibility would be to restrict the match.pd optimization to GIMPLE
only, another don't fold in C FE before this warning (well, we need to
fold the shift count operand to constant if possible), the following patch
just takes integral promotion into account in the warning code.

2023-03-04  Jakub Jelinek  <jakub@redhat.com>

PR c/107846
* c-warn.cc: Include langhooks.h.
(maybe_warn_shift_overflow): Set type0 to what TREE_TYPE (op0)
promotes to rather than TREE_TYPE (op0) itself, if TREE_TYPE (op0)
is narrower than type0 and unsigned, use wi::min_precision with
UNSIGNED and fold_convert op0 to type0 before emitting the warning.

* gcc.dg/pr107846.c: New test.

16 months agoc++: Don't defer local statics initialized with constant expressions [PR108702]
Jakub Jelinek [Sat, 4 Mar 2023 08:51:31 +0000 (09:51 +0100)]
c++: Don't defer local statics initialized with constant expressions [PR108702]

The stmtexpr19.C testcase used to be rejected as it has a static
variable in statement expression in constexpr context, but as that
static variable is initialized by constant expression, when P2647R1
was implemented we agreed to make it valid.

Now, as reported, the testcase compiles fine, but doesn't actually link
because the static variable isn't defined anywhere, and with -flto ICEs
because of this problem.  This is because we never
varpool_node::finalize_decl those vars, the constant expression in which
the DECL_EXPR is present for the static VAR_DECL is folded (constant
evaluated) into just the address of the VAR_DECL.
Now, similar testcase included below (do we want to include it in the
testsuite too?) works fine, because in
cp_finish_decl -> make_rtl_for_nonlocal_decl
we have since PR70353 fix:
  /* We defer emission of local statics until the corresponding
     DECL_EXPR is expanded.  But with constexpr its function might never
     be expanded, so go ahead and tell cgraph about the variable now.  */
  defer_p = ((DECL_FUNCTION_SCOPE_P (decl)
              && !var_in_maybe_constexpr_fn (decl))
             || DECL_VIRTUAL_P (decl));
and so don't defer them in constexpr/consteval functions.  The following
patch calls rest_of_decl_compilation which make_rtl_for_nonlocal_decl didn't
call when encountering DECL_EXPRs of such vars during constant evaluation
if they weren't finalized yet.

2023-03-04  Jakub Jelinek  <jakub@redhat.com>

PR c++/108702
* constexpr.cc: Include toplev.h.
(cxx_eval_constant_expression) <case DECL_EXPR>: When seeing a local
static initialized by constant expression outside of a constexpr
function which has been deferred by make_rtl_for_nonlocal_decl,
call rest_of_decl_compilation on it.

* g++.dg/ext/stmtexpr19.C: Use dg-do link rather than dg-do compile.

16 months agodiagnostics: Fix up selftests with $COLUMNS < 42 [PR108973]
Jakub Jelinek [Sat, 4 Mar 2023 08:48:17 +0000 (09:48 +0100)]
diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973]

As mentioned in the PR, GCC's diagnostics self-tests fail if $COLUMNS < 42.
Guarding each self-test with if (get_terminal_width () > 41) or similar
would be a maintainance nightmare (PR has a patch to do so without
reformatting to make it work for $COLUMNS in [30, 41] inclusive, but
I'm afraid going down to $COLUMNS 1 would mean marking everything).
Furthermore, the self-tests don't really emit stuff to the terminal,
but into a buffer, so using get_terminal_width () for it seems
inappropriate.  The following patch makes sure test_diagnostic_context
constructor uses exactly 80 columns wide caret max width, of course
some tests override it already if they want to test for behavior in narrower
cases.

2023-03-04  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/108973
* selftest-diagnostic.cc
(test_diagnostic_context::test_diagnostic_context): Set
caret_max_width to 80.

16 months agotestsuite: Skip gcc.dg/ipa/pr77653.c for CRIS
Hans-Peter Nilsson [Fri, 3 Mar 2023 16:49:01 +0000 (17:49 +0100)]
testsuite: Skip gcc.dg/ipa/pr77653.c for CRIS

CRIS defines DATA_ALIGNMENT such that alignment can be
applied differently to different data of the same type, when
"references to it must bind to the current definition"
(varasm.cc:align_variable).  Here, it means that more
alignment is then applied to g, but not f, so the test-case
fails because another message is emitted than the expected:
a same-alignment test dominates the not-discardable test,
and we get "Not unifying; original and alias have
incompatible alignments" rather than "Not unifying; alias
cannot be created; target is discardable".  Because this
DATA_ALIGNMENT behavior for CRIS depends on target options,
and this test is already artificial by the use of -fcommon,
better skip it.

* gcc.dg/ipa/pr77653.c: Skip for cris-*-*.

16 months agotestsuite: Skip gcc.dg/ifcvt-4.c for CRIS
Hans-Peter Nilsson [Thu, 2 Mar 2023 17:48:50 +0000 (18:48 +0100)]
testsuite: Skip gcc.dg/ifcvt-4.c for CRIS

CRIS has no conditional execution and no conditional moves.

* gcc.dg/ifcvt-4.c: Add cris-*-* to skip list.

16 months agotestsuite: Fix various scan-assembler identifiers not handling _-prefix
Hans-Peter Nilsson [Thu, 2 Mar 2023 17:11:20 +0000 (18:11 +0100)]
testsuite: Fix various scan-assembler identifiers not handling _-prefix

* g++.dg/cpp0x/pr84497.C: Handle USER_LABEL_PREFIX == "_" on
scan-assembler identifiers.
* gcc.dg/debug/btf/btf-enum64-1.c, gcc.dg/ipa/symver1.c: Ditto.

16 months agoDaily bump.
GCC Administrator [Sat, 4 Mar 2023 00:16:30 +0000 (00:16 +0000)]
Daily bump.

16 months agoanalyzer: start adding test coverage for OpenMP [PR109016]
David Malcolm [Fri, 3 Mar 2023 23:18:51 +0000 (18:18 -0500)]
analyzer: start adding test coverage for OpenMP [PR109016]

gcc/testsuite/ChangeLog:
PR analyzer/109016
* gcc.dg/analyzer/omp-parallel-for-1.c: New test.
* gcc.dg/analyzer/omp-parallel-for-get-min.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agoanalyzer: provide placeholder implementation of sprintf
David Malcolm [Fri, 3 Mar 2023 22:59:21 +0000 (17:59 -0500)]
analyzer: provide placeholder implementation of sprintf

Previously, the analyzer lacked a known_function implementation of
sprintf, and thus would handle calls to sprintf with the "anything could
happen" fallback.

Whilst working on PR analyzer/107565 I noticed that this was preventing
a lot of genuine memory leaks from being reported for Doom; fixing
thusly.

Integration testing of the effect of the patch shows a big increase in
true positives due to the case mentioned in Doom, and one new false
positive (in pcre2), which I'm tracking as PR analyzer/109014.

Comparison:
  GOOD:  67 -> 123 (+56); 10.91% -> 18.33%
   BAD: 547 -> 548 (+1)

where the affected warnings/projects are:

  -Wanalyzer-malloc-leak:
    GOOD:  0 -> 56 (+56);  0.00% -> 41.48%
     BAD: 79
      True positives: 0 -> 56 (+56)
        (all in Doom)

  -Wanalyzer-use-of-uninitialized-value:
    GOOD: 0;  0.00%
     BAD: 80 -> 81 (+1)
      False positives:
        pcre2-10.42: 0 -> 1 (+1)

gcc/analyzer/ChangeLog:
* kf.cc (class kf_sprintf): New.
(register_known_functions): Register it.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/doom-d_main-IdentifyVersion.c: New test.
* gcc.dg/analyzer/sprintf-1.c: New test.
* gcc.dg/analyzer/sprintf-concat.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agotestsuite: remove XFAIL in gcc.dg/analyzer/pr99716-1.c [PR108988]
David Malcolm [Fri, 3 Mar 2023 22:48:04 +0000 (17:48 -0500)]
testsuite: remove XFAIL in gcc.dg/analyzer/pr99716-1.c [PR108988]

Jakub's r13-6441-gdbeccab7a1f5dc fix for PR tree-optimization/108988
has fixed this failing analyzer test.

gcc/testsuite/ChangeLog:
PR tree-optimization/108988
* gcc.dg/analyzer/pr99716-1.c (test_2): Remove xfail.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agolibstdc++: testsuite: async.cc early timeout
Alexandre Oliva [Thu, 5 May 2022 02:41:38 +0000 (23:41 -0300)]
libstdc++: testsuite: async.cc early timeout

The async call and future variable initialization may take a while to
complete on uniprocessors, especially if the async call and other
unrelated processes run before context switches back to the main
thread.

Taking steady_begin only then sometimes causes the 11*100ms in the
slow clock, counted from before the async call, to not be enough for
the measured wait to last 1s in the steady clock.  I've seen it fall
short of 1s by as little as a third of a tenth of a second in some
cases, but in one surprisingly extreme case the elapsed wait time got
only up to 216.7ms.

Initializing both timestamps next to each other, before the async
call, appears to avoid the problem entirely.  I've renamed the
variable moved out of the block so as to avoid name hiding in the
subsequent block, that has another steady_begin variable.

The second wait fails a lot less frequently, but the 2s limit has been
exceeded, so I'm bumping up the max sleep to ~4s, and the tolerance to
3s.

for  libstdc++-v3/ChangeLog

* testsuite/30_threads/async/async.cc (test04): Initialize
steady_start, renamed from steady_begin, next to slow_start.
Increase tolerance for final wait.

16 months agod: Document that TypeInfo-based va_arg is not implemented
Iain Buclaw [Fri, 3 Mar 2023 19:39:59 +0000 (20:39 +0100)]
d: Document that TypeInfo-based va_arg is not implemented

PR d/108763

gcc/d/ChangeLog:

* implement-d.texi (Missing Features): Document that TypeInfo-based
va_arg is not implemented.

16 months ago[libstdc++] [prettyprint] add local std::string use to more tests
Alexandre Oliva [Fri, 3 Mar 2023 18:59:33 +0000 (15:59 -0300)]
[libstdc++] [prettyprint] add local std::string use to more tests

We're getting regressions after ugprading to GDB 13 in a few of the
libstdc++ pretty-printing tests.  It might seem like a GDB regression,
but that update has a new symbol reader, and Tom Tromey says it
exposes a latent problem in the pretty-printer, namely, when a name is
not defined locally in the local translation unit, GDB will look for
it in other units, and if multiple different definitions are
available, there are no guarantees as to which one it will find.

Since libstdc++ contains units in which std::string maps to different
types, in order to ensure the tests get the std::string definition we
expect, we need std::string to be present in the debug information for
the test itself, as we already do in other tests.

for  libstdc++-v3/ChangeLog

* testsuite/libstdc++-prettyprinters/80276.cc: Add
std::string to debug info.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.

16 months agolink pthread_join from std::thread ctor
Alexandre Oliva [Fri, 3 Mar 2023 18:59:36 +0000 (15:59 -0300)]
link pthread_join from std::thread ctor

Like pthread_create, pthread_join may fail to be statically linked in
absent strong uses, so add to user code strong references to both when
std::thread objects are created.

for  libstdc++-v3/ChangeLog

PR libstdc++/104852
PR libstdc++/95989
PR libstdc++/52590
* include/bits/std_thread.h (thread::_M_thread_deps): New
static implicitly-inline member function.
(std::thread template ctor): Pass it to _M_start_thread.
* src/c++11/thread.cc (thread::_M_start_thread): Name depend
parameter, force it live on entry.

16 months ago-Wdangling-pointer: don't mark SSA lhs sets as stores
Alexandre Oliva [Fri, 3 Mar 2023 18:59:30 +0000 (15:59 -0300)]
-Wdangling-pointer: don't mark SSA lhs sets as stores

check_dangling_stores has some weirdnesses that causes its behavior to
change when the target ABI requires C++ ctors to return this: while
scanning stmts backwards in e.g. the AS ctor on a target that returns
this in ctors, the scan first encounters a copy of this to the SSA
name used to hold the return value.  m_ptr_query.get_ref resolves lhs
(the return SSA name) to the rhs (the default SSA name for this), does
not skip it because auto_var_p is false for SSA_NAMEs, and proceeds to
add it to stores, which seems to prevent later attempts to add stores
into *this from succeeding, which disables warnings that should have
triggered.

This is also the case when the backwards search finds unrelated stores
to other fields of *this before it reaches stores that IMHO should be
warned about.  The store found first disables checking of other
stores, as if the store appearing later in the code would necessarily
overwrite the store that should be warned about.  I've added an
xfailed variant of the existing test (struct An) that triggers this
problem, but I'm not sure how to go about fixing it.

Meanwhile, this patch prevents assignments with SSA_NAMEs in the lhs
from being regarded as stores, which is enough to remove the
undesirable side effect on -Wdangling-pointer of ABI-mandated ctors'
returning this.  Another variant of the existing test (struct Al) that
demonstrates the problem regardless of this aspect of the ABI, and
that gets the desired warning with the proposed patch, but not
without.

Curiously, this fix exposes yet another problem in
Wdangling-pointer-5.c: it is the return stmt of the unrelated pointer
p, not the store into possibly-overlapping *vpp2, that caused the
warning to not be issued for the store in *vpp1.  I'm not sure whether
we should or should not warn in that case, but this patch adjusts the
test to reflect the behavior change.

for  gcc/ChangeLog

* gimple-ssa-warn-access.cc
(pass_waccess::check_dangling_stores): Skip non-stores.

for  gcc/testsuite/ChangeLog

* g++.dg/warn/Wdangling-pointer.C (warn_init_ref_member): Add
two new variants, one fixed, one xfailed.
* c-c++-common/Wdangling-pointer-5.c
(nowarn_store_arg_store_arg): Add now-expected warnings.

16 months ago[arm] adjust tests for quotes around +cdecp<N>
Alexandre Oliva [Fri, 3 Mar 2023 18:59:27 +0000 (15:59 -0300)]
[arm] adjust tests for quotes around +cdecp<N>

Back when quotes were added around "+cdecp<N>" in the "coproc must be
a constant immediate" error in arm-builtins.cc, tests for that message
lagged behind.  Fixed thusly.

for  gcc/testsuite/ChangeLog

* gcc.target/arm/acle/cde-errors.c: Adjust messages for quote
around +cdecp<N>.
* gcc.target/arm/acle/cde-mve-error-2.c: Likewise.

16 months ago[arm] adjust expectations for armv8_2-fp16-move-[12].c
Alexandre Oliva [Fri, 3 Mar 2023 18:59:24 +0000 (15:59 -0300)]
[arm] adjust expectations for armv8_2-fp16-move-[12].c

Commit 3a7ba8fd0cda387809e4902328af2473662b6a4a, a patch for
tree-ssa-sink, enabled the removal of basic blocks in ways that
affected the generated code for both of these tests, deviating from
the expectations of the tests.

The simplest case is that of -2, in which the edge unsplitting ends up
enabling a conditional return rather than a conditional branch to a
set-and-return block.  That looks like an improvement to me, but the
condition in which the branch or the return takes place can be
reasonably reversed (and, with the current code, it is), I've relaxed
the pattern in the test so as to accept reversed and unreversed
conditions applied to return or branch opcodes.

The situation in -1 is a little more elaborate: conditional branches
based on FP compares in test_select_[78] are initially expanded with
CCFPE compare-and-cbranch on G{T,E}, but when ce2 turns those into a
cmove, because now we have a different fallthrough block, the
condition is reversed, and that lands us with a compare-and-cmove
sequence that needs CCFP for UNL{E,T}.  The insn output reverses the
condition and swaps the cmove input operands, so the vcmp and vsel
insns come out the same except for the missing 'e' (for the compare
mode) in vcmp, so, since such reversals could have happened to any of
the tests depending on legitimate basic block layout, I've combined
the vcmp and vcmpe counts.

I see room for improving cmove sequence generation, e.g. trying direct
and reversed conditions and selecting the cheapest one (which would
require CCFP conditions to be modeled as more expensive than CCFPE),
or for some other machine-specific (peephole2?) optimization to turn
CCFP-requiring compare and cmove into CCFPE compare and swapped-inputs
cmove, but I haven't tried that.

for  gcc/testsuite/ChangeLog

* gcc.target/arm/armv8_2-fp16-move-1.c: Combine vcmp and vcmpe
expected counts into a single pattern.
* gcc.target/arm/armv8_2-fp16-move-2.c: Accept conditional
return and reversed conditions.

16 months ago[PR51534] [arm] split out pr51534 test for softfp
Alexandre Oliva [Fri, 3 Mar 2023 18:59:21 +0000 (15:59 -0300)]
[PR51534] [arm] split out pr51534 test for softfp

The test uses arm_hard_ok and arm_softfp_ok as if they were mutually
exclusive, but they test whether the corresponding -mfloat-abi= flag
is usable, not whether it is in effect, so it is possible for both to
pass, and then the test comes out with incorrect expectations
whichever the default float-abi is.

Separate the test into hard and softfp variants, and extend the softfp
variant to accept both ARM and Thumb opcodes; it unwarrantedly assumed
the latter.

for  gcc/testsuite/ChangeLog

PR target/51534
* gcc.target/arm/pr51534.c: Split softfp variant into...
* gcc.target/arm/pr51534s.c: ... this, and support ARM too.

16 months ago[arm] complete vmsr/vmrs blank and case adjustments
Alexandre Oliva [Fri, 3 Mar 2023 18:59:17 +0000 (15:59 -0300)]
[arm] complete vmsr/vmrs blank and case adjustments

Back in September last year, some of the vmsr and vmrs patterns had an
extraneous blank removed, and the case of register names lowered, but
another instance remained, and so did a testcase.

for  gcc/ChangeLog

* config/arm/vfp.md (*thumb2_movsi_vfp): Drop blank after tab
after vmsr and vmrs, and lower the case of P0.

for  gcc/testsuite/ChangeLog

* gcc.target/arm/acle/cde-mve-full-assembly.c: Drop blank
after tab after vmsr, and lower the case of P0.

16 months ago[PR104882] [arm] require mve hw for mve run test
Alexandre Oliva [Fri, 3 Mar 2023 18:59:14 +0000 (15:59 -0300)]
[PR104882] [arm] require mve hw for mve run test

The pr104882.c test is an execution test, but arm_v8_1m_mve_ok only
tests for compile-time support.  Add a requirement for mve hardware.

for  gcc/testsuite/ChangeLog

PR target/104882
* gcc.target/arm/simd/pr104882.c: Require mve hardware.

16 months agogcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006]
Jonathan Wakely [Fri, 3 Mar 2023 16:41:29 +0000 (16:41 +0000)]
gcc: Fix gdbhooks.py VecPrinter for vec<> as well as vec<>* [PR109006]

gcc/ChangeLog:

PR middle-end/109006
* gdbhooks.py (VecPrinter): Handle vec<T> as well as vec<T>*.

16 months agogcc: Adjust gdbhooks.py VecPrinter for vec layout changes [PR109006]
Jonathan Wakely [Fri, 3 Mar 2023 16:41:29 +0000 (16:41 +0000)]
gcc: Adjust gdbhooks.py VecPrinter for vec layout changes [PR109006]

gcc/ChangeLog:

PR middle-end/109006
* gdbhooks.py (VecPrinter): Adjust for new vec layout.

16 months agoc++: thinko in extract_local_specs [PR108998]
Patrick Palka [Fri, 3 Mar 2023 16:37:02 +0000 (11:37 -0500)]
c++: thinko in extract_local_specs [PR108998]

In order to fix PR100295, r13-4730-g18499b9f848707 attempted to make
extract_local_specs walk the given pattern twice, ignoring unevaluated
operands the first time around so that we prefer to process a local
specialization in an evaluated context if it appears in one (we process
each local specialization once even if it appears multiple times in the
pattern).

But there's a thinko in the patch, namely that we don't actually walk
the pattern twice since we don't clear the visited set for the second
walk (to avoid processing a local specialization twice) and so the root
node (and any node leading up to an unevaluated operand) is considered
visited already.  So the patch effectively made extract_local_specs
ignore unevaluated operands altogether, which this testcase demonstrates
isn't quite safe (extract_local_specs never sees 'aa' and we don't record
its local specialization, so later we try to specialize 'aa' on the spot
with the args {{int},{17}} which causes us to nonsensically substitute
its auto with 17.)

This patch fixes this by refining the second walk to start from the
trees we skipped over during the first walk.

PR c++/108998

gcc/cp/ChangeLog:

* pt.cc (el_data::skipped_trees): New data member.
(extract_locals_r): Push to skipped_trees any unevaluated
contexts that we skipped over.
(extract_local_specs): For the second walk, start from each
tree in skipped_trees.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-generic11.C: New test.

16 months agos390: libatomic: Fix 16 byte atomic {cas,load,store}
Stefan Schulze Frielinghaus [Fri, 3 Mar 2023 16:09:46 +0000 (17:09 +0100)]
s390: libatomic: Fix 16 byte atomic {cas,load,store}

This is a follow-up to commit a4c6bd0821099f6b8c0f64a96ffd9d01a025c413
introducing a runtime check for alignment for 16 byte atomic
compare-exchange, load, and store.

libatomic/ChangeLog:

* config/s390/cas_n.c: New file.
* config/s390/load_n.c: New file.
* config/s390/store_n.c: New file.

16 months agowaccess: Fix two -Wnonnull warning issues [PR108986]
Jakub Jelinek [Fri, 3 Mar 2023 15:11:11 +0000 (16:11 +0100)]
waccess: Fix two -Wnonnull warning issues [PR108986]

The following patch fixes 2 issues with the -Wnonnull warning.

One, fixed by the second hunk, is that the warning wording is bogus
since r11-3305, instead of printing
warning: argument 1 to â€˜int[static 7]’ is null where non-null expected [-Wnonnull]
it prints
warning: argument 1 to â€˜int[static 28]’ is null where non-null expected [-Wnonnull]
access_size is measured in bytes, so obviously will be correct as array
number of elements only if it is 1 byte element array.
In the function, access_nelts is either constant (if sizidx == -1) or
when the array size is determined by some other parameter, I believe a value
passed to that argument.
Later on we query the range of it:
      if (get_size_range (m_ptr_qry.rvals, access_nelts, stmt, sizrng, 1))
which I bet must just return accesS_nelts in sizrng[0] and [1] if it is
constant.  access_size is later computed as:
      tree access_size = NULL_TREE;
      if (tree_int_cst_sgn (sizrng[0]) >= 0)
        {
          if (COMPLETE_TYPE_P (argtype))
            {
...
                    wide_int minsize = wi::to_wide (sizrng[0], prec);
                    minsize *= wi::to_wide (argsize, prec);
                    access_size = wide_int_to_tree (sizetype, minsize);
                  }
            }
          else
            access_size = access_nelts;
        }
and immediately after this the code does:
      if (integer_zerop (ptr))
        {
          if (sizidx >= 0 && tree_int_cst_sgn (sizrng[0]) > 0)
            {
some other warning wording
            }
          else if (access_size && access.second.static_p)
            {
this spot
            }
        }
So, because argtype is complete, access_size has been multiplied by
argsize, but in case of this exact warning ("this spot" above)
I believe access_nelts must be really constant, otherwise
"some other warning wording" would handle it.  So, I think access_nelts
is exactly what we want to print there.

The other problem is that since the introduction of -Wdangling-pointer
in r12-6606, the pass has early and late instances and while lots of
stuff in the pass is guarded on being done in the late pass only,
this particular function is not, furthermore it is emitting two different
warnings in a loop and already messes up with stuff like clearing
warning suppression for one of the warning (ugh!).  The end effect is
that we warn twice about the same problem, once in the early and once in
the late pass.  Now, e.g. with -O2 -Wall we warn just once, during the
early pass, as it is then optimized away, so I think just making this
late warning only wouldn't be best.  This patch instead returns early
if either of the warnings is suppressed on the call stmt already.
I think if one of the passes warned on it already (even if say on some other
argument), then warning again (even on some other argument) is unnecessary,
if both problems are visible in the same pass we'll still warn about both.

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR c/108986
* gimple-ssa-warn-access.cc (pass_waccess::maybe_check_access_sizes):
Return immediately if OPT_Wnonnull or OPT_Wstringop_overflow_ is
suppressed on stmt.  For [static %E] warning, print access_nelts
rather than access_size.  Fix up comment wording.

* gcc.dg/Wnonnull-8.c: New test.

16 months agos390: Use arch14 instead of z16 for -march=native.
Robin Dapp [Wed, 1 Feb 2023 18:39:10 +0000 (19:39 +0100)]
s390: Use arch14 instead of z16 for -march=native.

When compiling on a system where binutils do not yet support the 'z16'
name assembling fails with -march=native on a z16 machine.
Currently, this is interpreted as -march=z16.  This patch uses -march=arch14
instead.

gcc/ChangeLog:

* config/s390/driver-native.cc (s390_host_detect_local_cpu): Use
arch14 instead of z16.

16 months agos390: Fix ifcvt test cases.
Robin Dapp [Wed, 1 Feb 2023 18:33:35 +0000 (19:33 +0100)]
s390: Fix ifcvt test cases.

We seem to flip flop between the "high" and "not low" variants of load on
condition.  Accept both in the affected test cases.

gcc/testsuite/ChangeLog:

* gcc.target/s390/ifcvt-two-insns-bool.c: Allow "high" and
"not low or equal" load on condition variant.
* gcc.target/s390/ifcvt-two-insns-int.c: Dito.
* gcc.target/s390/ifcvt-two-insns-long.c: Dito.

16 months agotestsuite: Do not expect partial vectorization for s390.
Robin Dapp [Thu, 2 Feb 2023 07:39:39 +0000 (08:39 +0100)]
testsuite: Do not expect partial vectorization for s390.

This changes SLP test expectations.  As we only vectorize when no more
than one rgroup is present, no vectorization is performed.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/slp-3.c: Adapt test expectation.
* gcc.dg/vect/slp-multitypes-11.c: Likewise.
* gcc.dg/vect/slp-perm-8.c: Likewise.

16 months agomoxie: enable LRA
Anthony Green [Fri, 3 Mar 2023 13:57:26 +0000 (08:57 -0500)]
moxie: enable LRA

Remove TARGET_LRA_P definition to enable LRA.

gcc/ChangeLog:

* config/moxie/moxie.cc (TARGET_LRA_P): Remove.

16 months agomoxie: fix memory constraints
Anthony Green [Fri, 3 Mar 2023 13:46:10 +0000 (08:46 -0500)]
moxie: fix memory constraints

Change define_constraint to define_memory_constraint where appropriate
to fix LRA for moxie.

gcc/ChangeLog:

* config/moxie/constraints.md (A, B, W): Change
define_constraint to define_memory_constraint.

16 months agodriver: toplev: Fix a typo
Xi Ruoyao [Fri, 3 Mar 2023 08:50:53 +0000 (16:50 +0800)]
driver: toplev: Fix a typo

The driver emits a warning when -fstack-check and
-fstack-clash-protection are used together, but the message refers to
"-fstack-clash_protection" (underline instead of dash).

gcc/ChangeLog:

* toplev.cc (process_options): Fix the spelling of
"-fstack-clash-protection".

16 months agotree-optimization/109002 - partial PRE miscompilation
Richard Biener [Fri, 3 Mar 2023 09:41:29 +0000 (10:41 +0100)]
tree-optimization/109002 - partial PRE miscompilation

Partial PRE ends up miscompiling the testcase in PR109002, likely
involving a corner case when inifinite loops are involved.  The
following avoids the miscompilation by addressing a long-standing
oddity that manifests in odd partial partial redundancies eliminated
that are full redundancies.  The oddity is that while we properly
PHI translate the PA_IN set from the successors when computing
PA_OUT but we fail to do the same for ANTIC_IN which is supposed
to be unioned.  That results in expressions with wrong virtual
operands being placed in the PA_OUT/IN sets and the pruning
machinery to go wrong because it assumes the expressions in the
sets have virtual operands that are valid in the respective blocks.

PR tree-optimization/109002
* tree-ssa-pre.cc (compute_partial_antic_aux): Properly
PHI-translate ANTIC_IN.

* gcc.dg/torture/pr109002.c: New testcase.

16 months agolibiberty: fix memory leak in pex-win32.c and refactor
Costas Argyris [Sun, 26 Feb 2023 16:34:11 +0000 (16:34 +0000)]
libiberty: fix memory leak in pex-win32.c and refactor

Fix memory leak of cmdline buffer and refactor to have
cleanup code appear once for all exit cases.

libiberty/ChangeLog:

* pex-win32.c (win32_spawn): Fix memory leak of cmdline
buffer and refactor to have cleanup code appear once
for all exit cases.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
16 months agogimple-fold: Fix up fputs -> fwrite folding [PR108988]
Jakub Jelinek [Fri, 3 Mar 2023 10:13:40 +0000 (11:13 +0100)]
gimple-fold: Fix up fputs -> fwrite folding [PR108988]

gimple_fold_builtin_fputs when folding fputs into fwrite emits the third
argument (INTEGER_CST) with incorrect type - get_maxval_strlen or c_strlen
return ssizetype, while fwrite argument is size_type_node.
The following patch fixes that, I've skimmed through the rest of
gimple-fold.cc and in all other places get_maxval_strlen/c_strlen result
was fold_converted to size_type_node already (or GIMPLE cast stmt has been
emitted directly etc.).

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/108988
* gimple-fold.cc (gimple_fold_builtin_fputs): Fold len to
size_type_node before passing it as argument to fwrite.  Formatting
fixes.

16 months agolibstdc++: Update Solaris baselines for GCC 13.0
Rainer Orth [Fri, 3 Mar 2023 10:02:50 +0000 (11:02 +0100)]
libstdc++: Update Solaris baselines for GCC 13.0

This patch updates the libstdc++ Solaris baselines for GCC 13.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (Solaris 11.3
and 11.4).

2022-12-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
Likewise.
* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
Likewise.

16 months agotarget/108738 - limit STV chain discovery
Richard Biener [Thu, 2 Mar 2023 12:43:51 +0000 (13:43 +0100)]
target/108738 - limit STV chain discovery

The following puts a hard limit on the inherently quadratic STV chain
discovery.  Without a limit for the compiler.i testcase in PR26854
we see at -O2

 machine dep reorg                  : 574.45 ( 53%)

with release checking while with the proposed limit it's

 machine dep reorg                  :   2.86 (  1%)

PR target/108738
* config/i386/i386.opt (--param x86-stv-max-visits): New param.
* doc/invoke.texi (--param x86-stv-max-visits): Document it.
* config/i386/i386-features.h (scalar_chain::max_visits): New.
(scalar_chain::build): Add bitmap parameter, return boolean.
(scalar_chain::add_insn): Likewise.
(scalar_chain::analyze_register_chain): Likewise.
* config/i386/i386-features.cc (scalar_chain::scalar_chain):
Initialize max_visits.
(scalar_chain::analyze_register_chain): When we exhaust
max_visits, abort.  Also abort when running into any
disallowed insn.
(scalar_chain::add_insn): Propagate abort.
(scalar_chain::build): Likewise.  When aborting amend
the set of disallowed insn with the insns set.
(convert_scalars_to_vector): Adjust.  Do not convert aborted
chains.

16 months agodebug/108772 - ICE with late debug generated with -flto
Richard Biener [Wed, 1 Mar 2023 09:01:10 +0000 (10:01 +0100)]
debug/108772 - ICE with late debug generated with -flto

When combining -g1 with -flto we run into the DIE location annotation
machinery for globals calling dwarf2out_late_global_decl but not
having any early generated DIE for function scope statics.  In
this process we'd generate a limbo DIE since also the function scope
doesn't have any early generated DIE.  The limbo handling then tries
to force a DIE for the context chain which ultimatively fails and
ICEs at the std namespace decl because at -g1 we don't represent that.

The following avoids this situation by making sure to never generate
any DIEs from dwarf2out_late_global_decl in the in_lto_p path
for function scope globals but rely on DIE generation for
the function to output a DIE for the local static (which doesn't
happen for -g1).

I explored a lot of other options to fix this but in the end this
seems to be the most spot-on fix with the least risk of unwanted
effects.

PR debug/108772
* dwarf2out.cc (dwarf2out_late_global_decl): Do not
generate a DIE for a function scope static.

* g++.dg/lto/pr108772_0.C: New testcase.

16 months ago[PR100127] Test for coroutine header in clang-compatible tests
Alexandre Oliva [Fri, 3 Mar 2023 04:47:00 +0000 (01:47 -0300)]
[PR100127] Test for coroutine header in clang-compatible tests

The test is compatible with clang as well as gcc, but ISTM that
testing for the __clang__ macro is just as potentially error-prone as
macros that used to be GCC-specific are now defined in compilers that
aim for GCC compatibility.  Use a __has_include feature test instead.

for  gcc/testsuite/ChangeLog

PR c++/100127
* g++.dg/coroutines/pr100127.C: Test for header rather than
compiler macro.
* g++.dg/coroutines/pr100772-a.C: Likewise.
* g++.dg/coroutines/pr100772-b.C: Likewise.

16 months ago[vxworks] make wint_t and wchar_t the same distinct type
Alexandre Oliva [Fri, 3 Mar 2023 04:47:04 +0000 (01:47 -0300)]
[vxworks] make wint_t and wchar_t the same distinct type

We used to define WINT_TYPE to WCHAR_TYPE, so that both wint_t and
wchar_t mapped to the same underlying type, but this caused a glitch
in Wstringop-overflow-6.C: on vxworks, wint_t is typedef'ed to
wchar_t, headers got included in the test that declared functions that
take wint_t parameters, and those conflicted with the builtin
declarations that had wint_t mapped to the underlying integral type.

The problem is that, in C++, wchar_t is a distinct type.  Having
wint_t be a typedef to wchar_t in the headers, but a typedef to
wchar_t's underlying integral type in builtins, makes for mismatches
between the declarations.

This patch defines WINT_TYPE to "wchar_t" for vxworks, and adjusts the
fallout, namely:

- since wchar_t may not have been defined yet when
  c_common_nodes_and_builtins runs, use the node already reserved for
  wchar_t for wint_t when WINT_TYPE is defined to wchar_t.

- for the same reason, when WINT_TYPE is wchar_t and we're not
  compiling C++ where wchar_t is a compiler built-in, define
  __WINT_TYPE__ to WCHAR_TYPE rather than WINT_TYPE, because wchar_t
  may not even be defined in the translation unit.

- recognize and handle wchar_type_node when type_suffix is called for
  wint_type_node.

for  gcc/ChangeLog

* config/vx-common.h (WINT_TYPE): Alias to "wchar_t".

for  gcc/c-family/ChangeLog

* c-common.cc (c_common_nodes_and_builtins): Take
wchar_type_node for wint_type_node when aliased.
(c_stddef_cpp_builtins): Define __WINT_TYPE__, when aliased to
wchar_t, to the underlying type rather than wchar_t in
non-C++.
* c-cppbuiltin.cc (type_suffix): Handle wchar_type_node.

16 months ago[c++] suppress redundant null-addr warn in pfn from pmfn
Alexandre Oliva [Fri, 3 Mar 2023 04:46:56 +0000 (01:46 -0300)]
[c++] suppress redundant null-addr warn in pfn from pmfn

When TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta, when
we warn about comparing a pointer-to-member-function with NULL, we
also warn about comparing the pointer-to-function extracted from it
with NULL, which is redundant.  Suppress the redundant warning.

for  gcc/cp/ChangeLog

* typeck.cc (cp_build_binary_op): Suppress redundant warning
for pfn null test in pmfn test with vbit-in-delta.

16 months agotestsuite: Tweak gcc.dg/attr-aligned.c for CRIS
Hans-Peter Nilsson [Thu, 16 Feb 2023 19:21:50 +0000 (20:21 +0100)]
testsuite: Tweak gcc.dg/attr-aligned.c for CRIS

tm.texi says for BIGGEST_ALIGNMENT (from which
__BIGGEST_ALIGNMENT__ is derived): "Biggest alignment that
any data type can require on this machine, in bits."

That is, using that value might be too strict for alignment
of *functions* and CRIS requires at least 16-bit alignment
for functions.  But, one purpose of the test is to test that
alignment can be set to a large but valid value, so pick
512, which has some use as a historically required alignment
for certain I/O descriptors.

* gcc.dg/attr-aligned.c: Adjust comment for ALIGN_MAX_STATIC.
(ALIGN_MAX_STATIC): Set to 512 for CRIS.

16 months agod: Allow vectors to be compared for identity [PR108946]
Iain Buclaw [Thu, 2 Mar 2023 23:00:44 +0000 (00:00 +0100)]
d: Allow vectors to be compared for identity [PR108946]

Vector equality and comparisons are now accepted by the language
implementation, but identity wasn't.  Implement it as an extra integer
comparison of the bit-casted bitmask.

PR d/108946

gcc/d/ChangeLog:

* d-target.cc (Target::isVectorOpSupported): Allow identity ops.
* expr.cc (ExprVisitor::visit (IdentityExp *)): Handle vector identity
comparisons.

gcc/testsuite/ChangeLog:

* gdc.dg/simd2a.d: Update test.
* gdc.dg/simd2b.d: Likewise.
* gdc.dg/simd2c.d: Likewise.
* gdc.dg/simd2d.d: Likewise.
* gdc.dg/simd2e.d: Likewise.
* gdc.dg/simd2f.d: Likewise.
* gdc.dg/simd2g.d: Likewise.
* gdc.dg/simd2h.d: Likewise.
* gdc.dg/simd2i.d: Likewise.
* gdc.dg/simd2j.d: Likewise.

16 months agod: Fix ICE on explicit immutable struct import [PR108877]
Iain Buclaw [Mon, 27 Feb 2023 19:46:18 +0000 (20:46 +0100)]
d: Fix ICE on explicit immutable struct import [PR108877]

Const and immutable types are built as variants of the type they are
derived from, and TYPE_STUB_DECL is not set for these variants.

PR d/108877

gcc/d/ChangeLog:

* imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
make_import on TYPE_MAIN_VARIANT.
(ImportVisitor::visit (AggregateDeclaration *)): Likewise.
(ImportVisitor::visit (ClassDeclaration *)): Likewise.

gcc/testsuite/ChangeLog:

* gdc.dg/imports/pr108877a.d: New test.
* gdc.dg/pr108877.d: New test.

16 months agod: Add test for PR d/108167 to the testsuite [PR108167]
Iain Buclaw [Mon, 27 Feb 2023 17:38:53 +0000 (18:38 +0100)]
d: Add test for PR d/108167 to the testsuite [PR108167]

The D front-end implementation got fixed in upstream, add test to the
gdc testsuite to check we don't regress on it.

PR d/108167

gcc/testsuite/ChangeLog:

* gdc.dg/pr108167.d: New test.

16 months agod: vector float comparison doesn't result in 0 or -1 [PR108945]
Iain Buclaw [Mon, 27 Feb 2023 15:02:21 +0000 (16:02 +0100)]
d: vector float comparison doesn't result in 0 or -1 [PR108945]

When comparing two vectors, the type of vector was used as the result of
the condition result.  This meant that for floating point comparisons,
each value would either be `0.0' or `-1.0' reinterpreted as an integer,
not the expected integral bitmask values `0' and `-1'.

Instead, use the comparison type determined by truth_type_for as the
result of the comparison.  If a reinterpret is later required by the
final conversion for generating CmpExp, it is still only going to
reinterpret one integer kind as another.

PR d/108945

gcc/d/ChangeLog:

* d-codegen.cc (build_boolop): Evaluate vector comparison as
the truth_type_for vector type.

gcc/testsuite/ChangeLog:

* gdc.dg/pr108945.d: New test.

16 months agoDaily bump.
GCC Administrator [Fri, 3 Mar 2023 00:16:38 +0000 (00:16 +0000)]
Daily bump.

16 months agotestsuite: Fix up memchr-3.c test [PR108991]
Jakub Jelinek [Thu, 2 Mar 2023 23:50:10 +0000 (00:50 +0100)]
testsuite: Fix up memchr-3.c test [PR108991]

The newly added dg-warning directive was missing the comment argument,
so the target selector was treated as comment and the warning was expected
on all targets when it should be expected only on llp64 targets.

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/108991
* gcc.dg/memchr-3.c: Add missing comment argument to dg-warning
before target selector.

16 months agolibquadmath: Assorted libquadmath strtoflt128 fixes [PR87204, PR94756]
Jakub Jelinek [Thu, 2 Mar 2023 23:40:13 +0000 (00:40 +0100)]
libquadmath: Assorted libquadmath strtoflt128 fixes [PR87204, PR94756]

This patch cherry-pickx 8 commits from glibc which fix various strtod_l
bugs.  Additionally, it makes mp_limb_t 64-bit on llp64 targets like
64-bit cygwin.

2023-03-03  niXman  <i.nixman@autistici.org>
    Jakub Jelinek  <jakub@redhat.com>

PR libquadmath/87204
PR libquadmath/94756
* printf/gmp-impl.h (mp_limb_t, mp_limb_signed_t, BITS_PER_MP_LIMB):
Use 64-bit limbs on LLP64 targets.
* strtod/strtod_l.c (round_and_return): Cherry-pick glibc
9310c284ae9 BZ #16151, 4406c41c1d6 BZ #16965 and fcd6b5ac36a
BZ #23279 fixes.
(____STRTOF_INTERNAL): Cherry-pick glibc b0debe14fcf BZ #23007,
5556d30caee BZ #18247, 09555b9721d and c6aac3bf366 BZ #26137 and
d84f25c7d87 fixes.

16 months agoc++, v3: Emit fundamental tinfos for _Float16/decltype(0.0bf16) types on ia32 with...
Jakub Jelinek [Thu, 2 Mar 2023 23:34:59 +0000 (00:34 +0100)]
c++, v3: Emit fundamental tinfos for _Float16/decltype(0.0bf16) types on ia32 with -mno-sse2 [PR108883]

_Float16 and decltype(0.0bf16) types are on x86 supported only with
-msse2.  On x86_64 that is the default, but on ia32 it is not.
We should still emit fundamental type tinfo for those types in
libsupc++.a/libstdc++.*, regardless of whether libsupc++/libstdc++
is compiled with -msse2 or not, as user programs can be compiled
with different ISA flags from libsupc++/libstdc++ and if they
are compiled with -msse2 and use std::float16_t or std::bfloat16_t
and need RTTI for it, it should work out of the box.  Furthermore,
libstdc++ ABI on ia32 shouldn't depend on whether the library
is compiled with -mno-sse or -msse2.

Unfortunately, just hacking up libsupc++ Makefile/configure so that
a single source is compiled with -msse2 isn't appropriate, because
that TU emits also code and the code should be able to run on CPUs
which libstdc++ supports.  We could add [[gnu::attribute ("no-sse2")]]
there perhaps conditionally, but it all gets quite ugly.

The following patch instead adds a target hook which allows the backend
to temporarily tweak registered types such that emit_support_tinfos
emits whatever is needed.

Additionally, it makes emit_support_tinfos_1 call emit_tinfo_decl
immediately, so that temporarily created dummy types for emit_support_tinfo
purposes only can be nullified again afterwards.  And removes the
previous fallback_* types used for dfloat*_type_node tinfos even when
decimal types aren't supported.

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR target/108883
gcc/
* target.h (emit_support_tinfos_callback): New typedef.
* targhooks.h (default_emit_support_tinfos): Declare.
* targhooks.cc (default_emit_support_tinfos): New function.
* target.def (emit_support_tinfos): New target hook.
* doc/tm.texi.in (emit_support_tinfos): Document it.
* doc/tm.texi: Regenerated.
* config/i386/i386.cc (ix86_emit_support_tinfos): New function.
(TARGET_EMIT_SUPPORT_TINFOS): Redefine.
gcc/cp/
* cp-tree.h (enum cp_tree_index): Remove CPTI_FALLBACK_DFLOAT*_TYPE
enumerators.
(fallback_dfloat32_type, fallback_dfloat64_type,
fallback_dfloat128_type): Remove.
* rtti.cc (emit_support_tinfo_1): If not emitted already, call
emit_tinfo_decl and remove from unemitted_tinfo_decls right away.
(emit_support_tinfos): Move &dfloat*_type_node from fundamentals array
into new fundamentals_with_fallback array.  Call emit_support_tinfo_1
on elements of that array too, with the difference that if
the type is NULL, use a fallback REAL_TYPE for it temporarily.
Drop the !targetm.decimal_float_supported_p () handling.  Call
targetm.emit_support_tinfos at the end.
* mangle.cc (write_builtin_type): Remove references to
fallback_dfloat*_type.  Handle bfloat16_type_node mangling.

16 months agojit, testsuite: fix a failing test by updating its error string [PR107999]
Guillaume Gomez [Thu, 2 Mar 2023 22:52:07 +0000 (17:52 -0500)]
jit, testsuite: fix a failing test by updating its error string [PR107999]

gcc/testsuite/ChangeLog:
PR jit/107999
* jit.dg/test-error-array-bounds.c: Update test.

Signed-off-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
16 months agoIRA: Use minimal cost for hard register movement
Vladimir N. Makarov [Thu, 2 Mar 2023 21:29:05 +0000 (16:29 -0500)]
IRA: Use minimal cost for hard register movement

This is the 2nd attempt to fix PR90706.  IRA calculates wrong AVR
costs for moving general hard regs of SFmode.  This was the reason for
spilling a pseudo in the PR.  In this patch we use smaller move cost
of hard reg in its natural and operand modes.

        PR rtl-optimization/90706

gcc/ChangeLog:

* ira-costs.cc: Include print-rtl.h.
(record_reg_classes, scan_one_insn): Add code to print debug info.
(record_operand_costs): Find and use smaller cost for hard reg
move.

gcc/testsuite/ChangeLog:

* gcc.target/avr/pr90706.c: New.

16 months agoamdgcn: Enable SIMD vectorization of math functions
Kwok Cheung Yeung [Thu, 2 Mar 2023 20:56:53 +0000 (20:56 +0000)]
amdgcn: Enable SIMD vectorization of math functions

Calls to vectorized versions of routines in the math library will now
be inserted when vectorizing code containing supported math functions.

2023-03-02  Kwok Cheung Yeung  <kcy@codesourcery.com>
    Paul-Antoine Arras  <pa@codesourcery.com>

gcc/
* builtins.cc (mathfn_built_in_explicit): New.
* config/gcn/gcn.cc: Include case-cfn-macros.h.
(mathfn_built_in_explicit): Add prototype.
(gcn_vectorize_builtin_vectorized_function): New.
(gcn_libc_has_function): New.
(TARGET_LIBC_HAS_FUNCTION): Define.
(TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Define.

gcc/testsuite/
* gcc.target/gcn/simd-math-1.c: New testcase.
* gcc.target/gcn/simd-math-2.c: New testcase.

libgomp/
* testsuite/libgomp.c/simd-math-1.c: New testcase.

16 months agoc++: more mce_false folding from cp_fully_fold_init [PR108243]
Patrick Palka [Thu, 2 Mar 2023 19:04:50 +0000 (14:04 -0500)]
c++: more mce_false folding from cp_fully_fold_init [PR108243]

We should also fold the overall initializer passed to cp_fully_fold_init
with mce_false, which allows folding of the copy-initialization of
'a1' in the below testcase (the initializer here is an AGGR_INIT_EXPR).

Unfortunately this doesn't help with direct- or default-initialization
because we don't call cp_fully_fold_init in that case, and even if we
did the initializer in that case is expressed as a bare CALL_EXPR
instead of an AGGR_INIT_EXPR, which cp_fully_fold_init can't really
fold.

PR c++/108243
PR c++/97553

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fully_fold): Add an internal overload that
additionally takes and propagate an mce_value parameter, and
define the existing public overload in terms of it.
(cp_fully_fold_init): Pass mce_false to cp_fully_fold.

gcc/testsuite/ChangeLog:

* g++.dg/opt/is_constant_evaluated3.C: New test.

16 months agoc++: constant non-copy-init is manifestly constant [PR108243]
Patrick Palka [Thu, 2 Mar 2023 19:03:21 +0000 (14:03 -0500)]
c++: constant non-copy-init is manifestly constant [PR108243]

According to [basic.start.static]/2 and [expr.const]/2, a variable
with static storage duration initialized with a constant initializer
has constant initialization, and such an initializer is manifestly
constant-evaluated.

For copy initialization, we're already getting this right because in
that case check_initializer would consistently call store_init_value,
which for TREE_STATIC variables calls fold_non_dependent_init with
m_c_e=true.

But for direct (or default) initialization, check_initializer doesn't
always call store_init_value.  We instead however always call
maybe_constant_init from expand_default_init[1], albeit with m_c_e=false
which means we don't get the "manifestly constant-evaluated" part right
for non-copy-init.

This patch fixes this by setting m_c_e=true in maybe_constant_init for
static storage duration variables, mainly for benefit of the call
to maybe_constant_init from expand_default_init.

[1]: this maybe_constant_init call isn't reached in the copy-init
case because there init is a CONSTRUCTOR rather than a TREE_LIST,
and so we exit early from expand_default_init, returning an INIT_EXPR.
This INIT_EXPR is ultimately what causes us to consistently hit the
store_init_value code path from check_initializer in the copy-init case.

PR c++/108243

gcc/cp/ChangeLog:

* constexpr.cc (maybe_constant_init_1): Override
manifestly_const_eval to true if is_static.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/is-constant-evaluated14.C: New test.

16 months agoanalyzer: fix uninit false +ves reading from DECL_HARD_REGISTER [PR108968]
David Malcolm [Thu, 2 Mar 2023 19:01:19 +0000 (14:01 -0500)]
analyzer: fix uninit false +ves reading from DECL_HARD_REGISTER [PR108968]

gcc/analyzer/ChangeLog:
PR analyzer/108968
* region-model.cc (region_model::get_rvalue_1): Handle VAR_DECLs
with a DECL_HARD_REGISTER by returning UNKNOWN.

gcc/testsuite/ChangeLog:
PR analyzer/108968
* gcc.dg/analyzer/uninit-pr108968-register.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agoc++, debug: Fix up locus of DW_TAG_imported_module [PR108716]
Jakub Jelinek [Thu, 2 Mar 2023 18:17:52 +0000 (19:17 +0100)]
c++, debug: Fix up locus of DW_TAG_imported_module [PR108716]

Before IMPORTED_DECL has been introduced in PR37410, we used to emit correct
DW_AT_decl_line on DW_TAG_imported_module on the testcase below, after that
change we haven't emitted it at all for a while and after some time
started emitting incorrect locus, in particular the location of } closing
the function.

The problem is that while we have correct EXPR_LOCATION on the USING_STMT,
when genericizing that USING_STMT into IMPORTED_DECL we don't copy the
location to DECL_SOURCE_LOCATION, so it gets whatever input_location happens
to be when it is created.

2023-03-02  Jakub Jelinek  <jakub@redhat.com>

PR debug/108716
* cp-gimplify.cc (cp_genericize_r) <case USING_STMT>: Set
DECL_SOURCE_LOCATION on IMPORTED_DECL to expression location
of USING_STMT or input_location.

* g++.dg/debug/dwarf2/pr108716.C: New test.

16 months agovect: Don't apply masks to operations on invariants [PR108979]
Richard Sandiford [Thu, 2 Mar 2023 16:39:50 +0000 (16:39 +0000)]
vect: Don't apply masks to operations on invariants [PR108979]

The loop body in the testcase contains an operation on invariants.
SLP detects this and can hoist/schedule the operation outside of
the loop.  However, after the fix for PR96373, we would try to
apply a loop mask to this operation, even though the mask is
defined in the loop.

The patch does what Richi suggested in the PR: suppress the
masking for externs and constants.

gcc/
PR tree-optimization/108979
* tree-vect-stmts.cc (vectorizable_operation): Don't mask
operations on invariants.

gcc/testsuite/
PR tree-optimization/108979
* gfortran.dg/vect/pr108979.f90: New test.

16 months agoc++: ICE with -Wmismatched-tags and member template [PR106259]
Marek Polacek [Wed, 1 Mar 2023 19:28:46 +0000 (14:28 -0500)]
c++: ICE with -Wmismatched-tags and member template [PR106259]

-Wmismatched-tags warns about the (harmless) struct/class mismatch.
For, e.g.,

  template<typename T> struct A { };
  class A<int> a;

it works by adding A<T> to the class2loc hash table while parsing the
class-head and then, while parsing the elaborate type-specifier, we
add A<int>.  At the end of c_parse_file we go through the table and
warn about the class-key mismatches.  In this PR we crash though; we
have

  template<typename T> struct A {
    template<typename U> struct W { };
  };
  struct A<int>::W<int> w; // #1

where while parsing A and #1 we've stashed
   A<T>
   A<T>::W<U>
   A<int>::W<int>
into class2loc.  Then in class_decl_loc_t::diag_mismatched_tags TYPE
is A<int>::W<int>, and specialization_of gets us A<int>::W<U>, which
is not in class2loc, so we crash on gcc_assert (cdlguide).  But it's
OK not to have found A<int>::W<U>, we should just look one "level" up,
that is, A<T>::W<U>.

It's important to handle class specializations, so e.g.

  template<>
  struct A<char> {
    template<typename U>
    class W { };
  };

where W's class-key is different than in the primary template above,
so we should warn depending on whether we're looking into A<char>
or into a different instantiation.

PR c++/106259

gcc/cp/ChangeLog:

* parser.cc (class_decl_loc_t::diag_mismatched_tags): If the first
lookup of SPEC didn't find anything, try to look for
most_general_template.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wmismatched-tags-11.C: New test.

16 months agos390: Add LEN_LOAD/LEN_STORE support.
Robin Dapp [Mon, 22 Aug 2022 09:05:39 +0000 (11:05 +0200)]
s390: Add LEN_LOAD/LEN_STORE support.

This patch adds LEN_LOAD/LEN_STORE support for z13 and newer.
It defines a bias value of -1 and implements the LEN_LOAD and LEN_STORE
optabs.

Add vll/vstl testcases adapted from Power.

Also change expectations for SLP testcases with more than one rgroup.

gcc/ChangeLog:

* config/s390/predicates.md (vll_bias_operand): Add -1 bias.
* config/s390/s390.cc (s390_option_override_internal): Make
partial vector usage the default from z13 on.
* config/s390/vector.md (len_load_v16qi): Add.
(len_store_v16qi): Add.

gcc/testsuite/ChangeLog:

* gcc.target/s390/s390.exp: Add partial subdirectory.
* gcc.target/s390/vector/vec-nopeel-2.c: Change test
expectation.
* lib/target-supports.exp: Add s390.
* gcc.target/s390/vector/partial/s390-vec-length-1.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-2.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-3.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-7.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-1.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-2.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-3.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-7.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-run-1.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-run-2.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-run-3.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-epil-run-7.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-1.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-2.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-3.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-7.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-run-1.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-run-2.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-run-3.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-full-run-7.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length-run-1.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-run-2.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-run-3.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-run-7.h: New test.
* gcc.target/s390/vector/partial/s390-vec-length-small.c: New test.
* gcc.target/s390/vector/partial/s390-vec-length.h: New test.

16 months agosimplify-rtx: Use byte in simplify_subreg rather than assume 0 offset
Andre Vieira [Thu, 2 Mar 2023 14:11:59 +0000 (14:11 +0000)]
simplify-rtx: Use byte in simplify_subreg rather than assume 0 offset

This patch fixes a missed review comment in an earlier patch using byte instead
of a 0 offset.  Also improves the comment as suggested.

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_subreg): Use byte instead
of constant 0 offset.

16 months agogcc.dg/memchr-3.c: Account for LLP64 warnings
Jonathan Yong [Mon, 27 Feb 2023 10:02:32 +0000 (10:02 +0000)]
gcc.dg/memchr-3.c: Account for LLP64 warnings

gcc/testsuite/ChangeLog:

PR middle-end/97956
* gcc.dg/memchr-3.c (memchr): Account for LLP64 warnings.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
16 months agogcc.dg/overflow-warn-9.c: Fix LLP64
Jonathan Yong [Mon, 27 Feb 2023 09:49:31 +0000 (09:49 +0000)]
gcc.dg/overflow-warn-9.c: Fix LLP64

gcc/testsuite/ChangeLog:

* gcc.dg/overflow-warn-9.c: Add LLP64 case.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
16 months agoMIPS: Bugfix for fix Dejagnu issues with RTL checking enabled.
Robert Suchanek [Thu, 2 Mar 2023 10:37:47 +0000 (10:37 +0000)]
MIPS: Bugfix for fix Dejagnu issues with RTL checking enabled.

gcc/ChangeLog:

* config/mips/mips.cc (mips_set_text_contents_type): Use HOST_WIDE_INT
instead of long.
* config/mips/mips-protos.h (mips_set_text_contents_type): Likewise.

Signed-off-by: Xin Liu <xin.liu@oss.cipunited.com>
16 months agoMIPS: Add buildtime option to set msa default
Junxian Zhu [Thu, 2 Mar 2023 10:30:21 +0000 (10:30 +0000)]
MIPS: Add buildtime option to set msa default

Add buildtime option to decide whether will compiler build with `-mmsa` option default.

gcc/ChangeLog:
* config.gcc: add -with-{no-}msa build option.
* config/mips/mips.h: Likewise.
* doc/install.texi: Likewise.

Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
16 months agoAvoid creating (const (reg ...)) [PR108603]
Richard Sandiford [Thu, 2 Mar 2023 10:30:21 +0000 (10:30 +0000)]
Avoid creating (const (reg ...)) [PR108603]

convert_memory_address_addr_space_1 has two modes: one in which it
tries to create a self-contained RTL expression (which might fail)
and one in which it can emit new instructions where necessary.

When handling a CONST, the function recurses into the CONST's
operand and then constifies the result.  But that's only valid if
the result is still a self-contained expression.  If new instructions
have been emitted, the expression will refer to the (non-constant)
results of those instructions.

In the PR, this caused us to emit a nonsensical (const (reg ...))
REG_EQUAL note.

gcc/
PR tree-optimization/108603
* explow.cc (convert_memory_address_addr_space_1): Only wrap
the result of a recursive call in a CONST if no instructions
were emitted.

gcc/testsuite/
PR tree-optimization/108603
* gcc.target/aarch64/sve/pr108603.c: New test.

16 months agovect: Fix voluntarily-masked negative conditionals [PR108430]
Richard Sandiford [Thu, 2 Mar 2023 10:30:20 +0000 (10:30 +0000)]
vect: Fix voluntarily-masked negative conditionals [PR108430]

vectorizable_condition checks whether a COND_EXPR condition is used
elsewhere with a loop mask.  If so, it applies the loop mask to the
COND_EXPR too, to reduce the number of live masks and to increase the
chance of combining the AND with the comparison.

There is also code to do this for inverted conditions.  E.g. if
we have a < b ? c : d and something else is conditional on !(a < b)
(such as a load in d), we use !(a < b) ? d : c and apply the loop
mask to !(a < b).

This inversion relied on the function's bitop1/bitop2 mechanism.
However, that mechanism is skipped if the condition is split out of
the COND_EXPR as a separate statement.  This meant that we could end
up using the inverse of the intended condition.

There is a separate way of negating the condition when a mask
is being applied (which is also used for EXTRACT_LAST reductions).
This patch uses that instead.

As well as the testcase, this fixes aarch64/sve/vcond_{4,17}_run.c.

gcc/
PR tree-optimization/108430
* tree-vect-stmts.cc (vectorizable_condition): Fix handling
of inverted condition.

gcc/testsuite/
PR tree-optimization/108430
* gcc.target/aarch64/sve/pr108430.c: New test.

16 months agofold-const: Ignore padding bits in native_interpret_expr REAL_CST reverse verificatio...
Jakub Jelinek [Thu, 2 Mar 2023 08:27:40 +0000 (09:27 +0100)]
fold-const: Ignore padding bits in native_interpret_expr REAL_CST reverse verification [PR108934]

In the following testcase we try to std::bit_cast a (pair of) integral
value(s) which has some non-zero bits in the place of x86 long double
(for 64-bit 16 byte type with 10 bytes actually loaded/stored by hw,
for 32-bit 12 byte) and starting with my PR104522 change we reject that
as native_interpret_expr fails on it.  The PR104522 change extends what
has been done before for MODE_COMPOSITE_P (but those don't have any padding
bits) to all floating point types, because e.g. the exact x86 long double
has various bit combinations we don't support, like
pseudo-(denormals,infinities,NaNs) or unnormals.  The HW handles some of
those as exceptional cases and others similarly to the non-pseudo ones.
But for the padding bits it actually doesn't load/store those bits at all,
it loads/stores 10 bytes.  So, I think we should exempt the padding bits
from the reverse comparison (the native_encode_expr bits for the padding
will be all zeros), which the following patch does.  For bit_cast it is
similar to e.g. ignoring padding bits if the destination is a structure
which has padding bits in there.

The change changed auto-init-4.c to how it has been behaving before the
PR105259 change, where some more VCEs can be now done.

2023-03-02  Jakub Jelinek  <jakub@redhat.com>

PR c++/108934
* fold-const.cc (native_interpret_expr) <case REAL_CST>: Before memcmp
comparison copy the bytes from ptr to a temporary buffer and clearing
padding bits in there.

* gcc.target/i386/auto-init-4.c: Revert PR105259 change.
* g++.target/i386/pr108934.C: New test.

16 months agoopenmp: Fix up error recovery for invalid structured bindings in OpenMP range for...
Jakub Jelinek [Thu, 2 Mar 2023 08:02:12 +0000 (09:02 +0100)]
openmp: Fix up error recovery for invalid structured bindings in OpenMP range for loops [PR105839]

The PR108503 temporary DECL_HAS_VALUE_EXPR_P clearing code can ICE
during recovery, because cp_finish_decomp when it detects errors and
reports them clears DECL_HAS_VALUE_EXPR_P, clears DECL_VALUE_EXPR and
sets TREE_TYPE of the structured binding vars to error_mark_node.
The PR108503 code had an assertion that DECL_HAS_VALUE_EXPR_P is set
so that it can clear it and restore later.

The following patch allows DECL_HAS_VALUE_EXPR_P to be unset if
type is error_mark_node and doesn't set it again in that case.

2023-03-02  Jakub Jelinek  <jakub@redhat.com>

PR c++/105839
* parser.cc (cp_convert_omp_range_for): Allow in assert
decomp_first_name without DECL_HAS_VALUE_EXPR_P if it has
error_mark_node type.
(cp_finish_omp_range_for): Don't set DECL_HAS_VALUE_EXPR_P back
on decls which have error_mark_node type.

* g++.dg/gomp/pr105839-1.C: New test.
* g++.dg/gomp/pr105839-2.C: New test.

16 months agotestsuite/108985 - missing vect_simd_clones target requirement on test
Richard Biener [Thu, 2 Mar 2023 08:03:37 +0000 (09:03 +0100)]
testsuite/108985 - missing vect_simd_clones target requirement on test

Added.

PR testsuite/108985
* gcc.dg/vect/pr108950.c: Require vect_simd_clones.

16 months agotestsuite: Fix g++.dg/ext/attr-copy-2.C for default_packed targets
Hans-Peter Nilsson [Wed, 1 Mar 2023 17:55:27 +0000 (18:55 +0100)]
testsuite: Fix g++.dg/ext/attr-copy-2.C for default_packed targets

For targets where the byte-wise structure element layout is
the same as for attribute-packed, you get a warning when
that's specified.  Thus, expect a warning for such targets.
Note the exclusion of bitfields.

* g++.dg/ext/attr-copy-2.C: Fix for default_packed targets.

16 months agotestsuite: Fix gcc.dg/attr-copy-6.c for user-label-prefixed targets
Hans-Peter Nilsson [Wed, 1 Mar 2023 16:30:07 +0000 (17:30 +0100)]
testsuite: Fix gcc.dg/attr-copy-6.c for user-label-prefixed targets

This fixes:
 Running /x/gcc/testsuite/gcc.dg/dg.exp ...
 ...
 FAIL: gcc.dg/attr-copy-6.c (test for excess errors)
for cris-elf, where gcc.log has:
Excess errors:
/x/gcc/testsuite/gcc.dg/attr-copy-6.c:91:3: error: 'fnoreturn_alias' aliased to undefined symbol 'fnoreturn_name'

Asm-declared identifiers need to prepend __USER_LABEL_PREFIX__
to the asm-name, something which is often overlooked because
it's empty for most targets.  N.B: attribute-alias does not need
the same treatment.  The identical construct added here, is in
several tests.

* gcc.dg/attr-copy-6.c: Prefix asm-declared name with
__USER_LABEL_PREFIX__.

16 months agoanalyzer: Support errno for newlib
Hans-Peter Nilsson [Wed, 1 Mar 2023 02:54:03 +0000 (03:54 +0100)]
analyzer: Support errno for newlib

Without this definition, the errno definition for newlib
isn't recognized as such, and these tests fail for newlib
targets:

FAIL: gcc.dg/analyzer/call-summaries-errno.c  (test for warnings, line 16)
FAIL: gcc.dg/analyzer/call-summaries-errno.c (test for excess errors)
FAIL: gcc.dg/analyzer/errno-1.c  (test for warnings, line 20)
FAIL: gcc.dg/analyzer/errno-1.c (test for excess errors)
FAIL: gcc.dg/analyzer/flex-without-call-summaries.c (test for excess errors)
FAIL: gcc.dg/analyzer/isatty-1.c  (test for warnings, line 31)
FAIL: gcc.dg/analyzer/isatty-1.c  (test for warnings, line 35)
FAIL: gcc.dg/analyzer/isatty-1.c  (test for warnings, line 46)
FAIL: gcc.dg/analyzer/isatty-1.c  (test for warnings, line 56)
FAIL: gcc.dg/analyzer/isatty-1.c (test for excess errors)

gcc/analyzer:
* kf.cc (register_known_functions): Add __errno function for newlib.

16 months agotestsuite: Handle "packed" targets in c-c++-common/auto-init-7.c and -8.c
Hans-Peter Nilsson [Wed, 15 Feb 2023 19:11:58 +0000 (20:11 +0100)]
testsuite: Handle "packed" targets in c-c++-common/auto-init-7.c and -8.c

Looks like there's a failed assumption that
sizeof (union U { char u1[5]; int u2; float u3; }) == 8.
However, for "packed" targets like cris-elf, it's 5.

These two tests have always failed for cris-elf.  I see from
https://gcc.gnu.org/pipermail/gcc-testresults/2023-February/777912.html
that they fail on pru-elf too, but I don't know if the cause
(and/or remedy) is the same.

IMHO this is preferred over the alternative; splitting up
that last line into two lines, like:
/* { dg-final { scan-tree-dump "temp4 = \
 .DEFERRED_INIT \\(8, 2, \&\"temp4\"" "gimple" { target { ! default_packed } } } } */
/* { dg-final { scan-tree-dump "temp4 = \
 .DEFERRED_INIT \\(5, 2, \&\"temp4\"" "gimple" { target default_packed } } } */

gcc/testsuite:
* c-c++-common/auto-init-7.c, c-c++-common/auto-init-8.c: Also
match targets where sizeof (union U) == 5, like "packed" targets.

16 months agoDaily bump.
GCC Administrator [Thu, 2 Mar 2023 00:17:28 +0000 (00:17 +0000)]
Daily bump.

16 months agoc++: can't eval PTRMEM_CST in incomplete class [PR107574]
Marek Polacek [Thu, 2 Feb 2023 23:15:37 +0000 (18:15 -0500)]
c++: can't eval PTRMEM_CST in incomplete class [PR107574]

Here we're attempting to evaluate a PTRMEM_CST in a class that hasn't
been completed yet, but that doesn't work:

        /* We can't lower this until the class is complete.  */
        if (!COMPLETE_TYPE_P (DECL_CONTEXT (member)))
          return cst;

and then this unlowered PTRMEM_CST is used as EXPR in

    tree op1 = build_nop (ptrdiff_type_node, expr);

and we crash in a subsequent cp_fold_convert which gets type=ptrdiff_type_node,
expr=PTRMEM_CST and does

  else if (TREE_CODE (expr) == PTRMEM_CST
           && same_type_p (TYPE_PTRMEM_CLASS_TYPE (type),
                           PTRMEM_CST_CLASS (expr)))

where TYPE_PTRMEM_CLASS_TYPE (type) is going to crash since the type
is ptrdiff_type_node.  We could just add a TYPE_PTRMEM_P check before
accessing TYPE_PTRMEM_CLASS_TYPE but I think it's nicer to explain why
we couldn't evaluate the expression.

PR c++/107574

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_constant_expression): Emit an error when
a PTRMEM_CST cannot be evaluated.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/ptrmem-cst1.C: New test.

16 months agoc++: streamline tf_qualifying_scope usage
Patrick Palka [Wed, 1 Mar 2023 23:25:44 +0000 (18:25 -0500)]
c++: streamline tf_qualifying_scope usage

This patch introduces a convenience wrapper tsubst_scope for tsubst'ing
into a type with tf_qualifying_scope set, and makes suitable callers use
it instead of explicitly setting tf_qualifying_scope.  This patch also
makes tsubst_copy immediately delegate to tsubst for all type trees,
which allows tsubst_copy to be oblivious to the tf_qualifying_scope flag.

gcc/cp/ChangeLog:

* pt.cc (tsubst_scope): Define.
(tsubst_decl) <case USING_DECL>: Call tsubst_scope instead of
calling tsubst_scope with tf_qualifying_scope set.
(tsubst_qualified_id): Call tsubst_scope instead of
calling tsubst with tf_qualifying_scope set.
(tsubst_copy): Immediately delegate to tsubst for all TYPE_P
trees.  Remove tf_qualifying_scope manipulation.
<case SCOPE_REF>: Call tsubst_scope instead of calling
tsubst with tf_qualifying_scope set.

16 months agoanalyzer: fixes to side-effects for built-in functions [PR107565]
David Malcolm [Wed, 1 Mar 2023 22:24:32 +0000 (17:24 -0500)]
analyzer: fixes to side-effects for built-in functions [PR107565]

Previously, if the analyzer saw a call to a non-pure and non-const
built-in function that it didn't have explicit knowledge of the behavior
of, it would fall back to assuming that the builtin could have arbitrary
behavior, similar to a function defined outside of the current TU.

However, this only worked for BUILTIN_NORMAL functions that matched
gimple_builtin_call_types_compatible_p; for BUILT_IN_FRONTEND and
BUILT_IN_MD, and for mismatched types the analyzer would erroneously
assume that the builtin had no side-effects, leading e.g. to
PR analyzer/107565, where the analyzer falsely reported that x
was still uninitialized after this target-specific builtin:

  _1 = __builtin_ia32_rdrand64_step (&x);

This patch generalizes the handling to cover all classes of builtin,
fixing the above false positive.

Unfortunately this patch regresses gcc.dg/analyzer/pr99716-1.c due to
the:
  fprintf (fp, "hello");
being optimized to:
   __builtin_fwrite ("hello", 1, (ssizetype)5, fp_6);
and the latter has gimple_builtin_call_types_compatible_p return false,
whereas the original call had it return true.  I'm assuming that this is
an optimization bug, and have filed it as PR middle-end/108988.  The
effect on the analyzer is that it fails to recognize the call to
__builtin_fwrite and instead assumes arbitraty side-effects (including
that it could call fclose on fp, hence the report about the leak goes
away).

I tried various more involved fixes with new heuristics for handling
built-ins that aren't explicitly covered by the analyzer, but those
fixes tended to introduce many more regressions, so I'm going with this
simpler fix.

gcc/analyzer/ChangeLog:
PR analyzer/107565
* region-model.cc (region_model::on_call_pre): Flatten logic by
returning early.  Consolidate logic for detecting const and pure
functions.  When considering whether an unhandled built-in
function has side-effects, consider all kinds of builtin, rather
than just BUILT_IN_NORMAL, and don't require
gimple_builtin_call_types_compatible_p.

gcc/testsuite/ChangeLog:
PR analyzer/107565
* gcc.dg/analyzer/builtins-pr107565.c: New test.
* gcc.dg/analyzer/pr99716-1.c (test_2): Mark the leak as xfailing.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 months agolibstdc++: Fix typo in comment in bits/cow_string.h
Jonathan Wakely [Wed, 1 Mar 2023 18:58:38 +0000 (18:58 +0000)]
libstdc++: Fix typo in comment in bits/cow_string.h

libstdc++-v3/ChangeLog:

* include/bits/cow_string.h: Fix typo in comment.

16 months agolibstdc++: Make std::chrono::current_zone() default to UTC
Jonathan Wakely [Tue, 28 Feb 2023 21:07:48 +0000 (21:07 +0000)]
libstdc++: Make std::chrono::current_zone() default to UTC

This is consistent with the behaviour of glibc, which assumes UTC when
/etc/localtime and TZ do not identify a valid time zone. The fallback
tzdb used when no valid tzdata exists always contains the UTC zone, so
this change means we have a valid tzdb and valid current zone even in
the degenerate case.

With this default we no longer need the AIX-specific kluge to try and
identify TZ values specifying a 0-offset zone. We can just use the UTC
default for those, as it has the same effect.

It's still possible for chrono::current_zone() to fail, because the user
could have provided a custom tzdata.zi file which doesn't contain the
UTC time zone, so the "UTC" default would fail to find a valid zone, and
throw an exception. That's just user error, they should not provide bad
data and expect reasonable behaviour.

libstdc++-v3/ChangeLog:

* src/c++20/tzdb.cc (chrono::tzdb::current_zone()) Use "UTC" if
current time zone cannot be determined.
* testsuite/std/time/tzdb/1.cc: Remove conditions based on
HAVE_TZDB macro and test all members unconditionally.

16 months agoc++: unevaluated array new-expr size constantness [PR108219]
Patrick Palka [Wed, 1 Mar 2023 19:09:37 +0000 (14:09 -0500)]
c++: unevaluated array new-expr size constantness [PR108219]

Here we're mishandling the unevaluated array new-expressions due to a
supposed non-constant array size ever since r12-5253-g4df7f8c79835d569
made us no longer perform constant evaluation of non-manifestly-constant
expressions within unevaluated contexts.  This shouldn't make a difference
here since the array sizes are constant literals, except they're expressed
as NON_LVALUE_EXPR location wrappers around INTEGER_CST, wrappers which
used to get stripped as part of constant evaluation and now no longer do.
Moreover it means build_vec_init can't constant fold the MINUS_EXPR
'maxindex' passed from build_new_1 when in an unevaluated context (since
it tries reducing it via maybe_constant_value called with mce_unknown).

This patch fixes these issues by making maybe_constant_value (and
fold_non_dependent_expr) try folding an unevaluated non-manifestly-constant
operand via fold(), as long as it simplifies to a simple constant, rather
than doing no simplification at all.  This covers e.g. simple arithmetic
and casts including stripping of location wrappers around INTEGER_CST.

In passing, this patch also fixes maybe_constant_value to avoid constant
evaluating an unevaluated operand when called with mce_false, by adjusting
the early exit test appropriately.

Co-authored-by: Jason Merrill <jason@redhat.com>
PR c++/108219
PR c++/108218

gcc/cp/ChangeLog:

* constexpr.cc (fold_to_constant): Define.
(maybe_constant_value): Move up early exit test for unevaluated
operands.  Try reducing an unevaluated operand to a constant via
fold_to_constant.
(fold_non_dependent_expr_template): Add early exit test for
CONSTANT_CLASS_P nodes.  Try reducing an unevaluated operand
to a constant via fold_to_constant.
* cp-tree.h (fold_to_constant): Declare.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/new6.C: New test.
* g++.dg/cpp2a/concepts-new1.C: New test.