]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
19 months agoLoongArch: Fix warnings building libgcc
Xi Ruoyao [Sat, 9 Dec 2023 14:08:37 +0000 (22:08 +0800)] 
LoongArch: Fix warnings building libgcc

We are excluding loongarch-opts.h from target libraries, but now struct
loongarch_target and gcc_options are not declared in the target
libraries, causing:

In file included from ../.././gcc/options.h:8,
                 from ../.././gcc/tm.h:49,
                 from ../../../gcc/libgcc/fixed-bit.c:48:
../../../gcc/libgcc/../gcc/config/loongarch/loongarch-opts.h:57:41:
warning: 'struct gcc_options' declared inside parameter list will not
be visible outside of this definition or declaration
   57 |                                  struct gcc_options *opts,
      |                                         ^~~~~~~~~~~

So exclude the declarations referring to the C++ structs as well.

gcc/ChangeLog:

* config/loongarch/loongarch-opts.h (la_target): Move into #if
for loongarch-def.h.
(loongarch_init_target): Likewise.
(loongarch_config_target): Likewise.
(loongarch_update_gcc_opt_status): Likewise.

19 months agoLoongArch: Allow -mcmodel=extreme and model attribute with -mexplicit-relocs=auto
Xi Ruoyao [Thu, 7 Dec 2023 07:45:30 +0000 (15:45 +0800)] 
LoongArch: Allow -mcmodel=extreme and model attribute with -mexplicit-relocs=auto

There seems no real reason to require -mexplicit-relocs=always for
-mcmodel=extreme or model attribute.  As the linker does not know how to
relax a 3-operand la.local or la.global pseudo instruction, just emit
explicit relocs for SYMBOL_PCREL64, and under TARGET_CMODEL_EXTREME also
SYMBOL_GOT_DISP.

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_explicit_relocs_p):
Return true for SYMBOL_PCREL64.  Return true for SYMBOL_GOT_DISP
if TARGET_CMODEL_EXTREME.
(loongarch_split_symbol): Check for la_opt_explicit_relocs !=
EXPLICIT_RELOCS_NONE instead of TARGET_EXPLICIT_RELOCS.
(loongarch_print_operand_reloc): Likewise.
(loongarch_option_override_internal): Likewise.
(loongarch_handle_model_attribute): Likewise.
* doc/invoke.texi (-mcmodel=extreme): Update the compatibility
between it and -mexplicit-relocs=.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/attr-model-3.c: New test.
* gcc.target/loongarch/attr-model-4.c: New test.
* gcc.target/loongarch/func-call-extreme-3.c: New test.
* gcc.target/loongarch/func-call-extreme-4.c: New test.

19 months agotree-optimization/112939 - VN PHI visiting and -ftrivial-auto-var-init
Richard Biener [Mon, 11 Dec 2023 12:00:18 +0000 (13:00 +0100)] 
tree-optimization/112939 - VN PHI visiting and -ftrivial-auto-var-init

The following builds upon the last fix, making sure we only value-number
to visited (un-)defs, otherwise prefer .VN_TOP.

PR tree-optimization/112939
* tree-ssa-sccvn.cc (visit_phi): When all args are undefined
make sure we end up with a value that was visited, otherwise
fall back to .VN_TOP.

* gcc.dg/pr112939.c: New testcase.

19 months agoDon't assume it's AVX_U128_CLEAN after call_insn whose abi.mode_clobber(V4DImode...
liuhongt [Thu, 7 Dec 2023 01:17:27 +0000 (09:17 +0800)] 
Don't assume it's AVX_U128_CLEAN after call_insn whose abi.mode_clobber(V4DImode) deosn't contains all SSE_REGS.

If the function desn't clobber any sse registers or only clobber
128-bit part, then vzeroupper isn't issued before the function exit.
the status not CLEAN but ANY after the function.

Also for sibling_call, it's safe to issue an vzeroupper. Also there
could be missing vzeroupper since there's no mode_exit for
sibling_call_p.

gcc/ChangeLog:

PR target/112891
* config/i386/i386.cc (ix86_avx_u128_mode_after): Return
AVX_U128_ANY if callee_abi doesn't clobber all_sse_regs to
align with ix86_avx_u128_mode_needed.
(ix86_avx_u128_mode_needed): Return AVX_U128_ClEAN for
sibling_call.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr112891.c: New test.
* gcc.target/i386/pr112891-2.c: New test.

19 months agountyped calls: enable target switching [PR112334]
Alexandre Oliva [Tue, 12 Dec 2023 04:12:04 +0000 (01:12 -0300)] 
untyped calls: enable target switching [PR112334]

The computation of apply_args_size and apply_result_size is saved in a
static variable, so that the corresponding _mode arrays are
initialized only once.  That is not compatible with switchable
targets, and ARM's arm_set_current_function, by saving and restoring
target globals, exercises this problem with a testcase such as that in
the PR, in which more than one function in the translation unit calls
__builtin_apply or __builtin_return, respectively.

This patch moves the _size statics into the target_builtins array,
with a bit of ugliness over _plus_one so that zero initialization of
the struct does the right thing.

for  gcc/ChangeLog

PR target/112334
* builtins.h (target_builtins): Add fields for apply_args_size
and apply_result_size.
* builtins.cc (apply_args_size, apply_result_size): Cache
results in fields rather than in static variables.
(get_apply_args_size, set_apply_args_size): New.
(get_apply_result_size, set_apply_result_size): New.

19 months agoi386: Fix missed APX_NDD check for shift/rotate expanders [PR 112943]
Hongyu Wang [Mon, 11 Dec 2023 11:30:42 +0000 (19:30 +0800)] 
i386: Fix missed APX_NDD check for shift/rotate expanders [PR 112943]

The ashl/lshr/ashr expanders calls ix86_expand_binary_operator, while
they will be called for some post-reload split, and TARGET_APX_NDD is
required for these calls to avoid force-load to memory at postreload
stage.

gcc/ChangeLog:

PR target/112943
* config/i386/i386.md (ashl<mode>3): Add TARGET_APX_NDD to
ix86_expand_binary_operator call.
(<insn><mode>3): Likewise for rshift.
(<insn>di3): Likewise for DImode rotate.
(<insn><mode>3): Likewise for SWI124 rotate.

gcc/testsuite/ChangeLog:

PR target/112943
* gcc.target/i386/pr112943.c: New test.

19 months agoanalyzer: add more test coverage for tainted modulus
David Malcolm [Tue, 12 Dec 2023 02:29:39 +0000 (21:29 -0500)] 
analyzer: add more test coverage for tainted modulus

Add more test coverage for r14-6349-g0bef72539e585d.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/plugin.exp: Add taint-modulus.c to
analyzer_kernel_plugin.c tests.
* gcc.dg/plugin/taint-modulus.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
19 months agoMAINTAINERS: Update my email address
Feng Wang [Tue, 12 Dec 2023 02:16:59 +0000 (02:16 +0000)] 
MAINTAINERS: Update my email address

ChangeLog:

* MAINTAINERS: Update my email address

19 months agoRISC-V: Add avail interface into function_group_info
Feng Wang [Mon, 11 Dec 2023 01:14:17 +0000 (01:14 +0000)] 
RISC-V: Add avail interface into function_group_info

Patch v3: Fix typo and remove the modification of rvv.exp.
Patch v2: Using variadic macro and add the dependency into t-riscv.

In order to add other extension about vector,this patch add
unsigned int (*avail) (void) into function_group_info to determine
whether to register the intrinsic based on ISA info.
gcc/ChangeLog:

* config/riscv/riscv-vector-builtins-functions.def (DEF_RVV_FUNCTION):
Add AVAIL argument.
(read_vl): Using AVAIL argument default value.
(vlenb): Ditto.
(vsetvl): Ditto.
(vsetvlmax): Ditto.
(vle): Ditto.
(vse): Ditto.
(vlm): Ditto.
(vsm): Ditto.
(vlse): Ditto.
(vsse): Ditto.
(vluxei8): Ditto.
(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.
(vleff): Ditto.
(vadd): Ditto.
(vsub): Ditto.
(vrsub): Ditto.
(vneg): Ditto.
(vwaddu): Ditto.
(vwsubu): Ditto.
(vwadd): Ditto.
(vwsub): Ditto.
(vwcvt_x): Ditto.
(vwcvtu_x): Ditto.
(vzext): Ditto.
(vsext): Ditto.
(vadc): Ditto.
(vmadc): Ditto.
(vsbc): Ditto.
(vmsbc): Ditto.
(vand): Ditto.
(vor): Ditto.
(vxor): Ditto.
(vnot): Ditto.
(vsll): Ditto.
(vsra): Ditto.
(vsrl): Ditto.
(vnsrl): Ditto.
(vnsra): Ditto.
(vncvt_x): Ditto.
(vmseq): Ditto.
(vmsne): Ditto.
(vmsltu): Ditto.
(vmslt): Ditto.
(vmsleu): Ditto.
(vmsle): Ditto.
(vmsgtu): Ditto.
(vmsgt): Ditto.
(vmsgeu): Ditto.
(vmsge): Ditto.
(vminu): Ditto.
(vmin): Ditto.
(vmaxu): Ditto.
(vmax): Ditto.
(vmul): Ditto.
(vmulh): Ditto.
(vmulhu): Ditto.
(vmulhsu): Ditto.
(vdivu): Ditto.
(vdiv): Ditto.
(vremu): Ditto.
(vrem): Ditto.
(vwmul): Ditto.
(vwmulu): Ditto.
(vwmulsu): Ditto.
(vmacc): Ditto.
(vnmsac): Ditto.
(vmadd): Ditto.
(vnmsub): Ditto.
(vwmaccu): Ditto.
(vwmacc): Ditto.
(vwmaccsu): Ditto.
(vwmaccus): Ditto.
(vmerge): Ditto.
(vmv_v): Ditto.
(vsaddu): Ditto.
(vsadd): Ditto.
(vssubu): Ditto.
(vssub): Ditto.
(vaaddu): Ditto.
(vaadd): Ditto.
(vasubu): Ditto.
(vasub): Ditto.
(vsmul): Ditto.
(vssrl): Ditto.
(vssra): Ditto.
(vnclipu): Ditto.
(vnclip): Ditto.
(vfadd): Ditto.
(vfsub): Ditto.
(vfrsub): Ditto.
(vfadd_frm): Ditto.
(vfsub_frm): Ditto.
(vfrsub_frm): Ditto.
(vfwadd): Ditto.
(vfwsub): Ditto.
(vfwadd_frm): Ditto.
(vfwsub_frm): Ditto.
(vfmul): Ditto.
(vfdiv): Ditto.
(vfrdiv): Ditto.
(vfmul_frm): Ditto.
(vfdiv_frm): Ditto.
(vfrdiv_frm): Ditto.
(vfwmul): Ditto.
(vfwmul_frm): Ditto.
(vfmacc): Ditto.
(vfnmsac): Ditto.
(vfmadd): Ditto.
(vfnmsub): Ditto.
(vfnmacc): Ditto.
(vfmsac): Ditto.
(vfnmadd): Ditto.
(vfmsub): Ditto.
(vfmacc_frm): Ditto.
(vfnmacc_frm): Ditto.
(vfmsac_frm): Ditto.
(vfnmsac_frm): Ditto.
(vfmadd_frm): Ditto.
(vfnmadd_frm): Ditto.
(vfmsub_frm): Ditto.
(vfnmsub_frm): Ditto.
(vfwmacc): Ditto.
(vfwnmacc): Ditto.
(vfwmsac): Ditto.
(vfwnmsac): Ditto.
(vfwmacc_frm): Ditto.
(vfwnmacc_frm): Ditto.
(vfwmsac_frm): Ditto.
(vfwnmsac_frm): Ditto.
(vfsqrt): Ditto.
(vfsqrt_frm): Ditto.
(vfrsqrt7): Ditto.
(vfrec7): Ditto.
(vfrec7_frm): Ditto.
(vfmin): Ditto.
(vfmax): Ditto.
(vfsgnj): Ditto.
(vfsgnjn): Ditto.
(vfsgnjx): Ditto.
(vfneg): Ditto.
(vfabs): Ditto.
(vmfeq): Ditto.
(vmfne): Ditto.
(vmflt): Ditto.
(vmfle): Ditto.
(vmfgt): Ditto.
(vmfge): Ditto.
(vfclass): Ditto.
(vfmerge): Ditto.
(vfmv_v): Ditto.
(vfcvt_x): Ditto.
(vfcvt_xu): Ditto.
(vfcvt_rtz_x): Ditto.
(vfcvt_rtz_xu): Ditto.
(vfcvt_f): Ditto.
(vfcvt_x_frm): Ditto.
(vfcvt_xu_frm): Ditto.
(vfcvt_f_frm): Ditto.
(vfwcvt_x): Ditto.
(vfwcvt_xu): Ditto.
(vfwcvt_rtz_x): Ditto.
(vfwcvt_rtz_xu) Ditto.:
(vfwcvt_f): Ditto.
(vfwcvt_x_frm): Ditto.
(vfwcvt_xu_frm) Ditto.:
(vfncvt_x): Ditto.
(vfncvt_xu): Ditto.
(vfncvt_rtz_x): Ditto.
(vfncvt_rtz_xu): Ditto.
(vfncvt_f): Ditto.
(vfncvt_rod_f): Ditto.
(vfncvt_x_frm): Ditto.
(vfncvt_xu_frm): Ditto.
(vfncvt_f_frm): Ditto.
(vredsum): Ditto.
(vredmaxu): Ditto.
(vredmax): Ditto.
(vredminu): Ditto.
(vredmin): Ditto.
(vredand): Ditto.
(vredor): Ditto.
(vredxor): Ditto.
(vwredsum): Ditto.
(vwredsumu): Ditto.
(vfredusum): Ditto.
(vfredosum): Ditto.
(vfredmax): Ditto.
(vfredmin): Ditto.
(vfredusum_frm): Ditto.
(vfredosum_frm): Ditto.
(vfwredosum): Ditto.
(vfwredusum): Ditto.
(vfwredosum_frm): Ditto.
(vfwredusum_frm): Ditto.
(vmand): Ditto.
(vmnand): Ditto.
(vmandn): Ditto.
(vmxor): Ditto.
(vmor): Ditto.
(vmnor): Ditto.
(vmorn): Ditto.
(vmxnor): Ditto.
(vmmv): Ditto.
(vmclr): Ditto.
(vmset): Ditto.
(vmnot): Ditto.
(vcpop): Ditto.
(vfirst): Ditto.
(vmsbf): Ditto.
(vmsif): Ditto.
(vmsof): Ditto.
(viota): Ditto.
(vid): Ditto.
(vmv_x): Ditto.
(vmv_s): Ditto.
(vfmv_f): Ditto.
(vfmv_s): Ditto.
(vslideup): Ditto.
(vslidedown): Ditto.
(vslide1up): Ditto.
(vslide1down): Ditto.
(vfslide1up): Ditto.
(vfslide1down): Ditto.
(vrgather): Ditto.
(vrgatherei16): Ditto.
(vcompress): Ditto.
(vundefined): Ditto.
(vreinterpret): Ditto.
(vlmul_ext): Ditto.
(vlmul_trunc): Ditto.
(vset): Ditto.
(vget): Ditto.
(vcreate): Ditto.
(vlseg): Ditto.
(vsseg): Ditto.
(vlsseg): Ditto.
(vssseg): Ditto.
(vluxseg): Ditto.
(vloxseg): Ditto.
(vsuxseg): Ditto.
(vsoxseg): Ditto.
(vlsegff): Ditto.
* config/riscv/riscv-vector-builtins.cc (DEF_RVV_FUNCTION): Using variadic macro.
* config/riscv/riscv-vector-builtins.h (struct function_group_info):
Add avail function interface into struct.
* config/riscv/t-riscv: Add dependency
* config/riscv/riscv-vector-builtins-avail.h: New file.The definition of AVAIL marco.

19 months agoRISC-V: Move RVV POLY VALUE estimation from riscv.cc to riscv-v.cc[NFC]
Juzhe-Zhong [Tue, 12 Dec 2023 02:06:38 +0000 (10:06 +0800)] 
RISC-V: Move RVV POLY VALUE estimation from riscv.cc to riscv-v.cc[NFC]

This patch moves RVV POLY VALUE estimation from riscv.cc to riscv-v.cc for
future better maintain like other target hook implementation.

Committed as it is obviously a code refinement.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (estimated_poly_value): New function.
* config/riscv/riscv-v.cc (estimated_poly_value): Ditto.
* config/riscv/riscv.cc (riscv_estimated_poly_value): Move RVV POLY
VALUE estimation to riscv-v.cc

19 months agoLoongArch: Fix eh_return epilogue for normal returns.
Yang Yujie [Fri, 8 Dec 2023 10:01:18 +0000 (18:01 +0800)] 
LoongArch: Fix eh_return epilogue for normal returns.

On LoongArch, the regitsters $r4 - $r7 (EH_RETURN_DATA_REGNO) will be saved
and restored in the function prologue and epilogue if the given function calls
__builtin_eh_return.  This causes the return value to be overwritten on normal
return paths and breaks a rare case of libgcc's _Unwind_RaiseException.

gcc/ChangeLog:

* config/loongarch/loongarch.cc: Do not restore the saved eh_return
data registers ($r4-$r7) for a normal return of a function that calls
__builtin_eh_return elsewhere.
* config/loongarch/loongarch-protos.h: Same.
* config/loongarch/loongarch.md: Same.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/eh_return-normal-return.c: New test.

19 months agoMAINTAINERS: Add myself to write after approval and DCO
Feng Wang [Tue, 12 Dec 2023 01:58:07 +0000 (01:58 +0000)] 
MAINTAINERS: Add myself to write after approval and DCO

ChangeLog:

* MAINTAINERS: Add myself to write after approval

19 months agoDaily bump.
GCC Administrator [Tue, 12 Dec 2023 00:17:22 +0000 (00:17 +0000)] 
Daily bump.

19 months agotestsuite: Disable -fstack-protector* for some strub tests
Jakub Jelinek [Mon, 11 Dec 2023 22:52:46 +0000 (23:52 +0100)] 
testsuite: Disable -fstack-protector* for some strub tests

In our distro builds, we test with
RUNTESTFLAGS='--target_board=unix\{,-fstack-protector-strong\}'
because SSP is something we use widely in the distribution.
4 new strub test FAIL with that option though, as can be
seen with a simple
make check-gcc check-g++ RUNTESTFLAGS='--target_board=unix\{,-fstack-protector-strong\} dg.exp=strub-O*'
- in particular, the expand dump
\[(\]call\[^\n\]*strub_leave.*\n\[(\]code_label
regexps see code_labels in there introduced for stack protector.

The following patch fixes it by using -fno-stack-protector for these
explicitly.

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

* c-c++-common/strub-O2fni.c: Add -fno-stack-protector to dg-options.
* c-c++-common/strub-O3fni.c: Likewise.
* c-c++-common/strub-Os.c: Likewise.
* c-c++-common/strub-Og.c: Likewise.

19 months agoFix regression causing ICE for structs with VLAs [PR 112488]
Martin Uecker [Wed, 15 Nov 2023 08:22:55 +0000 (09:22 +0100)] 
Fix regression causing ICE for structs with VLAs [PR 112488]

A previous patch that fixed several ICEs related to size expressions
of VM types (PR c/70418, ...) caused a regression for structs where
a DECL_EXPR is not generated anymore although reqired.  We now call
add_decl_expr introduced by the previous patch from finish_struct.
The function is revised with a new argument to not set the TYPE_NAME
for the type to the DECL_EXPR in this specific case.

PR c/112488

gcc/c
* c-decl.cc (add_decl_expr): Revise.
(finish_struct): Create DECL_EXPR.
* c-parser.cc (c_parser_struct_or_union_specifier): Call
finish_struct with expression for VLA sizes.
* c-tree.h (finish_struct): Add argument.

gcc/testsuite
* gcc.dg/pr112488-1.c: New test.
* gcc.dg/pr112488-2.c: New test.
* gcc.dg/pr112898.c: New test.
* gcc.misc-tests/gcov-pr85350.c: Adapt.

19 months agoResolve ICE in 'gcc/fortran/trans-openmp.cc:gfc_omp_call_is_alloc'
Thomas Schwinge [Mon, 11 Dec 2023 21:52:54 +0000 (22:52 +0100)] 
Resolve ICE in 'gcc/fortran/trans-openmp.cc:gfc_omp_call_is_alloc'

Fix-up for recent commit 2505a8b41d3b74a545755a278f3750a29c1340b6
"OpenMP: Minor '!$omp allocators' cleanup", which caused:

    {+FAIL: gfortran.dg/gomp/allocate-5.f90   -O  (internal compiler error: tree check: expected class 'type', have 'declaration' (function_decl) in gfc_omp_call_is_alloc, at fortran/trans-openmp.cc:8386)+}
    [-PASS:-]{+FAIL:+} gfortran.dg/gomp/allocate-5.f90   -O  (test for excess errors)

..., and similarly in 'libgomp.fortran/allocators-1.f90',
'libgomp.fortran/allocators-2.f90', 'libgomp.fortran/allocators-3.f90',
'libgomp.fortran/allocators-4.f90', 'libgomp.fortran/allocators-5.f90'.

gcc/fortran/
* trans-openmp.cc (gfc_omp_call_is_alloc): Resolve ICE.

19 months agoanalyzer: fix uninitialized bitmap [PR112955]
David Malcolm [Mon, 11 Dec 2023 21:18:56 +0000 (16:18 -0500)] 
analyzer: fix uninitialized bitmap [PR112955]

In r14-5566-g841008d3966c0f I added a new ctor for
feasibility_state, but failed to call bitmap_clear
on m_snodes_visited.

Fixed thusly.

gcc/analyzer/ChangeLog:
PR analyzer/112955
* engine.cc (feasibility_state::feasibility_state): Initialize
m_snodes_visited.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
19 months agoTreat "p" in asms as addressing VOIDmode
Richard Sandiford [Mon, 11 Dec 2023 19:43:38 +0000 (19:43 +0000)] 
Treat "p" in asms as addressing VOIDmode

check_asm_operands was inconsistent about how it handled "p"
after RA compared to before RA.  Before RA it tested the address
with a void (unknown) memory mode:

    case CT_ADDRESS:
      /* Every address operand can be reloaded to fit.  */
      result = result || address_operand (op, VOIDmode);
      break;

After RA it deferred to constrain_operands, which used the mode
of the operand:

if ((GET_MODE (op) == VOIDmode
     || SCALAR_INT_MODE_P (GET_MODE (op)))
    && (strict <= 0
|| (strict_memory_address_p
     (recog_data.operand_mode[opno], op))))
  win = true;

Using the mode of the operand is necessary for special predicates,
where it is used to give the memory mode.  But for asms, the operand
mode is simply the mode of the address itself (so DImode on 64-bit
targets), which doesn't say anything about the addressed memory.

This patch uses VOIDmode for asms but continues to use the operand
mode for .md insns.  It's needed to avoid a regression in the
testcase with the late-combine pass.

Fixing this made me realise that recog_level2 was doing duplicate
work for asms after RA.

gcc/
* recog.cc (constrain_operands): Pass VOIDmode to
strict_memory_address_p for 'p' constraints in asms.
* rtl-ssa/changes.cc (recog_level2): Skip redundant constrain_operands
for asms.

gcc/testsuite/
* gcc.target/aarch64/prfm_imm_offset_2.c: New test.

19 months agotestsuite: update mangling
Jason Merrill [Mon, 11 Dec 2023 19:05:48 +0000 (14:05 -0500)] 
testsuite: update mangling

Since r14-6064-gc3f281a0c1ca50 this test was checking for the wrong
mangling, but it still passed on targets that support ABI compatibility
aliases.  Let's avoid generating those aliases when checking mangling.

gcc/ChangeLog:

* common.opt: Add comment.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-explicit-inst1.C: Specify ABI v18.
* g++.dg/cpp2a/concepts-explicit-inst1a.C: New test.

19 months ago-finline-stringops: avoid too-wide smallest_int_mode_for_size [PR112784]
Alexandre Oliva [Mon, 11 Dec 2023 18:09:28 +0000 (15:09 -0300)] 
-finline-stringops: avoid too-wide smallest_int_mode_for_size [PR112784]

smallest_int_mode_for_size may abort when the requested mode is not
available.  Call int_mode_for_size instead, that signals the
unsatisfiable request in a more graceful way.

for  gcc/ChangeLog

PR middle-end/112784
* expr.cc (emit_block_move_via_loop): Call int_mode_for_size
for maybe-too-wide sizes.
(emit_block_cmp_via_loop): Likewise.

for  gcc/testsuite/ChangeLog

PR middle-end/112784
* gcc.target/i386/avx512cd-inline-stringops-pr112784.c: New.

19 months ago-finline-stringops: check base blksize for memset [PR112778]
Alexandre Oliva [Mon, 11 Dec 2023 18:09:25 +0000 (15:09 -0300)] 
-finline-stringops: check base blksize for memset [PR112778]

The recently-added logic for -finline-stringops=memset introduced an
assumption that doesn't necessarily hold, namely, that
can_store_by_pieces of a larger size implies can_store_by_pieces by
smaller sizes.  Checks for all sizes the by-multiple-pieces machinery
might use before committing to an expansion pattern.

for  gcc/ChangeLog

PR target/112778
* builtins.cc (can_store_by_multiple_pieces): New.
(try_store_by_multiple_pieces): Call it.

for  gcc/testsuite/ChangeLog

PR target/112778
* gcc.dg/inline-mem-cmp-pr112778.c: New.

19 months ago-finline-stringops: don't assume ptr_mode ptr in memset [PR112804]
Alexandre Oliva [Mon, 11 Dec 2023 18:09:22 +0000 (15:09 -0300)] 
-finline-stringops: don't assume ptr_mode ptr in memset [PR112804]

On aarch64 -milp32, and presumably on other such targets, ptr can be
in a different mode than ptr_mode in the testcase.  Cope with it.

for  gcc/ChangeLog

PR target/112804
* builtins.cc (try_store_by_multiple_pieces): Use ptr's mode
for the increment.

for  gcc/testsuite/ChangeLog

PR target/112804
* gcc.target/aarch64/inline-mem-set-pr112804.c: New.

19 months agomultiflags: fix doc warning
Alexandre Oliva [Mon, 11 Dec 2023 18:09:19 +0000 (15:09 -0300)] 
multiflags: fix doc warning

Comply with dubious doc warning that after an @xref there must be a
comma or a period, not a close parentheses.

for  gcc/ChangeLog

* doc/invoke.texi (multiflags): Add period after @xref to
silence warning.

19 months agostrub: disable on rl78
Alexandre Oliva [Mon, 11 Dec 2023 18:09:16 +0000 (15:09 -0300)] 
strub: disable on rl78

rl78 allocation of virtual registers to physical registers doesn't
operate on asm statements, and strub uses asm statements in the
runtime and in the generated code, to the point that the runtime
won't build.  Force strub disabled on that target.

for  gcc/ChangeLog

* config/rl78/rl78.cc (TARGET_HAVE_STRUB_SUPPORT_FOR): Disable.

19 months agostrub: add note on attribute access
Alexandre Oliva [Mon, 11 Dec 2023 18:09:13 +0000 (15:09 -0300)] 
strub: add note on attribute access

Document why attribute access doesn't need the same treatment as fn
spec, and check that the assumption behind it holds.

for  gcc/ChangeLog

* ipa-strub.cc (pass_ipa_strub::execute): Check that we don't
add indirection to pointer parameters, and document attribute
access non-interactions.

19 months agolibgfortran: Replace mutex with rwlock
Lipeng Zhu [Sat, 9 Dec 2023 15:39:45 +0000 (10:39 -0500)] 
libgfortran: Replace mutex with rwlock

This patch try to introduce the rwlock and split the read/write to
unit_root tree and unit_cache with rwlock instead of the mutex to
increase CPU efficiency. In the get_gfc_unit function, the percentage
to step into the insert_unit function is around 30%, in most instances,
we can get the unit in the phase of reading the unit_cache or unit_root
tree. So split the read/write phase by rwlock would be an approach to
make it more parallel.

BTW, the IPC metrics can gain around 9x in our test
server with 220 cores. The benchmark we used is
https://github.com/rwesson/NEAT

libgcc/ChangeLog:

* gthr-posix.h (__GTHREAD_RWLOCK_INIT): New macro.
(__gthrw): New function.
(__gthread_rwlock_rdlock): New function.
(__gthread_rwlock_tryrdlock): New function.
(__gthread_rwlock_wrlock): New function.
(__gthread_rwlock_trywrlock): New function.
(__gthread_rwlock_unlock): New function.

libgfortran/ChangeLog:

* io/async.c (DEBUG_LINE): New macro.
* io/async.h (RWLOCK_DEBUG_ADD): New macro.
(CHECK_RDLOCK): New macro.
(CHECK_WRLOCK): New macro.
(TAIL_RWLOCK_DEBUG_QUEUE): New macro.
(IN_RWLOCK_DEBUG_QUEUE): New macro.
(RDLOCK): New macro.
(WRLOCK): New macro.
(RWUNLOCK): New macro.
(RD_TO_WRLOCK): New macro.
(INTERN_RDLOCK): New macro.
(INTERN_WRLOCK): New macro.
(INTERN_RWUNLOCK): New macro.
* io/io.h (struct gfc_unit): Change UNIT_LOCK to UNIT_RWLOCK in
a comment.
(unit_lock): Remove including associated internal_proto.
(unit_rwlock): New declarations including associated internal_proto.
(dec_waiting_unlocked): Use WRLOCK and RWUNLOCK on unit_rwlock
instead of __gthread_mutex_lock and __gthread_mutex_unlock on
unit_lock.
* io/transfer.c (st_read_done_worker): Use WRLOCK and RWUNLOCK on
unit_rwlock instead of LOCK and UNLOCK on unit_lock.
(st_write_done_worker): Likewise.
* io/unit.c: Change UNIT_LOCK to UNIT_RWLOCK in 'IO locking rules'
comment. Use unit_rwlock variable instead of unit_lock variable.
(get_gfc_unit_from_unit_root): New function.
(get_gfc_unit): Use RDLOCK, WRLOCK and RWUNLOCK on unit_rwlock
instead of LOCK and UNLOCK on unit_lock.
(close_unit_1): Use WRLOCK and RWUNLOCK on unit_rwlock instead of
LOCK and UNLOCK on unit_lock.
(close_units): Likewise.
(newunit_alloc): Use RWUNLOCK on unit_rwlock instead of UNLOCK on
unit_lock.
* io/unix.c (find_file): Use RDLOCK and RWUNLOCK on unit_rwlock
instead of LOCK and UNLOCK on unit_lock.
(flush_all_units): Use WRLOCK and RWUNLOCK on unit_rwlock instead
of LOCK and UNLOCK on unit_lock.

19 months agoPR rtl-optimization/112380: Defend against CLOBBERs in combine.cc
Roger Sayle [Mon, 11 Dec 2023 17:30:20 +0000 (17:30 +0000)] 
PR rtl-optimization/112380: Defend against CLOBBERs in combine.cc

This patch addresses PR rtl-optimization/112380, an ICE-on-valid regression
where a (clobber (const_int 0)) encounters a sanity checking gcc_assert
(at line 7554) in simplify-rtx.cc.  These CLOBBERs are used internally
by GCC's combine pass much like error_mark_node is used by various
language front-ends.

The solutions are either to handle/accept these CLOBBERs through-out
(or in more places in) the middle-end's RTL optimizers, including functions
in simplify-rtx.cc that are used by passes other than combine, and/or
attempt to prevent these CLOBBERs escaping from try_combine into the
RTX/RTL stream.  The benefit of the second approach is that it actually
allows for better optimization: when try_combine fails to simplify an
expression instead of substituting a CLOBBER to avoid the instruction
pattern being recognized, noticing the CLOBBER often allows combine
to attempt alternate simplifications/transformations looking for those
that can be recognized.

This first alternative is the minimal fix to address the CLOBBER
encountered in the bugzilla PR.

2023-12-11  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR rtl-optimization/112380
* combine.cc (expand_field_assignment): Check if gen_lowpart
returned a CLOBBER, and avoid calling gen_simplify_binary with
it if so.

gcc/testsuite/ChangeLog
PR rtl-optimization/112380
* gcc.dg/pr112380.c: New test case.

19 months agoTestsuite: restrict test to nonpic targets
Francois-Xavier Coudert [Mon, 11 Dec 2023 08:26:23 +0000 (09:26 +0100)] 
Testsuite: restrict test to nonpic targets

The test is currently failing on x86_64-apple-darwin.

gcc/testsuite/ChangeLog:

PR testsuite/112297
* gcc.target/i386/pr100936.c: Require nonpic target.

19 months agoc++: add fixed testcase [PR63378]
Patrick Palka [Mon, 11 Dec 2023 16:59:33 +0000 (11:59 -0500)] 
c++: add fixed testcase [PR63378]

We accept this testcase since r12-4453-g79802c5dcc043a.

PR c++/63378

gcc/testsuite/ChangeLog:

* g++.dg/template/fnspec3.C: New test.

19 months agoaarch64: Fix wrong code for bfloat when f16 is enabled [PR 111867]
Andrew Pinski [Sun, 10 Dec 2023 04:02:24 +0000 (20:02 -0800)] 
aarch64: Fix wrong code for bfloat when f16 is enabled [PR 111867]

The problem here is when f16 is enabled, movbf_aarch64 accepts `Ufc`
as a constraint:
     [ w        , Ufc ; fconsts     , fp16  ] fmov\t%h0, %1
But that is for fmov values and in this case fmov represents f16 rather than bfloat16 values.
This means we would get the wrong value in the register.

Built and tested for aarch64-linux-gnu with no regressions.  Also tested with `-march=armv9-a+sve2,
gcc.dg/torture/bfloat16-basic.c and gcc.dg/torture/bfloat16-builtin.c no longer fail.

gcc/ChangeLog:

PR target/111867
* config/aarch64/aarch64.cc (aarch64_float_const_representable_p): For BFmode,
only accept +0.0.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
19 months agoMATCH: (convert)(zero_one !=/== 0/1) for outer type and zero_one type are the same
Andrew Pinski [Sat, 11 Nov 2023 23:54:10 +0000 (15:54 -0800)] 
MATCH: (convert)(zero_one !=/== 0/1) for outer type and zero_one type are the same

When I moved two_value to match.pd, I removed the check for the {0,+-1}
as I had placed it after the {0,+-1} case for cond in match.pd.
In the case of {0,+-1} and non boolean, before we would optmize those
case to just `(convert)a` but after we would get `(convert)(a != 0)`
which was not handled anyways to just `(convert)a`.
So this adds a pattern to match `(convert)(zeroone != 0)` and simplify
to `(convert)zeroone`.

Also this optimizes (convert)(zeroone == 0) into (zeroone^1) if the
type match. Removing the opposite transformation from fold.
The opposite transformation was added with
https://gcc.gnu.org/pipermail/gcc-patches/2006-February/190514.html
It is no longer considered the canonicalization either, even VRP will
transform it back into `(~a) & 1` so removing it is a good idea.

Note the testcase pr69270.c needed a slight update due to not matching
exactly a scan pattern, this update makes it more robust and will match
before and afterwards and if there are other changes in this area too.

Note the testcase gcc.target/i386/pr110790-2.c needs a slight update
for better code generation in LP64 bit mode.

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

gcc/ChangeLog:

PR tree-optimization/111972
PR tree-optimization/110637
* match.pd (`(convert)(zeroone !=/== CST)`): Match
and simplify to ((convert)zeroone){,^1}.
* fold-const.cc (fold_binary_loc): Remove
transformation of `(~a) & 1` and `(a ^ 1) & 1`
into `(convert)(a == 0)`.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr110637-1.c: New test.
* gcc.dg/tree-ssa/pr110637-2.c: New test.
* gcc.dg/tree-ssa/pr110637-3.c: New test.
* gcc.dg/tree-ssa/pr111972-1.c: New test.
* gcc.dg/tree-ssa/pr69270.c: Update testcase.
* gcc.target/i386/pr110790-2.c: Update testcase.
* gcc.dg/fold-even-1.c: Removed.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
19 months agoanalyzer: Remove check of unsigned_char in maybe_undo_optimize_bit_field_compare.
Andrew Pinski [Tue, 11 Jul 2023 04:53:24 +0000 (21:53 -0700)] 
analyzer: Remove check of unsigned_char in maybe_undo_optimize_bit_field_compare.

The check for the type seems unnecessary and gets in the way sometimes.
Also with a patch I am working on for match.pd, it causes a failure to happen.
Before my patch the IR was:
  _1 = BIT_FIELD_REF <s, 8, 16>;
  _2 = _1 & 1;
  _3 = _2 != 0;
  _4 = (int) _3;
  __analyzer_eval (_4);

Where _2 was an unsigned char type.
And After my patch we have:
  _1 = BIT_FIELD_REF <s, 8, 16>;
  _2 = (int) _1;
  _3 = _2 & 1;
  __analyzer_eval (_3);

But in this case, the BIT_AND_EXPR is in an int type.

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

gcc/analyzer/ChangeLog:

* region-model-manager.cc (maybe_undo_optimize_bit_field_compare): Remove
the check for type being unsigned_char_type_node.

19 months agoexpr: catch more `a*bool` while expanding [PR 112935]
Andrew Pinski [Sat, 9 Dec 2023 21:43:23 +0000 (13:43 -0800)] 
expr: catch more `a*bool` while expanding  [PR 112935]

After r14-1655-g52c92fb3f40050 (and the other commits
which touch zero_one_valued_p), we end up with a with
`bool * a` but where the bool is an SSA name that might not
have non-zero bits set on it (to 0x1) even though it
does the non-zero bits would be 0x1.
The case of coremarks, it is only phiopt4 which adds the new
ssa name and nothing afterwards updates the nonzero bits on it.
This fixes the regression by using gimple_zero_one_valued_p
rather than tree_nonzero_bits to match the cases where the
SSA_NAME didn't have the non-zero bits set.
gimple_zero_one_valued_p handles one level of cast and also
and an `&`.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR middle-end/112935
* expr.cc (expand_expr_real_2): Use
gimple_zero_one_valued_p instead of tree_nonzero_bits
to find boolean defined expressions.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
19 months ago[PATCH] wrong code on m68k with -mlong-jump-table-offsets and -malign-int (PR target...
Mikael Pettersson [Mon, 11 Dec 2023 15:40:41 +0000 (08:40 -0700)] 
[PATCH] wrong code on m68k with -mlong-jump-table-offsets and -malign-int (PR target/112413)

On m68k the compiler assumes that the PC-relative jump-via-jump-table
instruction and the jump table are adjacent with no padding in between.

When -mlong-jump-table-offsets is combined with -malign-int, a 2-byte
nop may be inserted before the jump table, causing the jump to add the
fetched offset to the wrong PC base and thus jump to the wrong address.

Fixed by referencing the jump table via its label. On the test case
in the PR the object code change is (the moveal at 16 is the nop):

    a:  6536            bcss 42 <f+0x42>
    c:  e588            lsll #2,%d0
    e:  203b 0808       movel %pc@(18 <f+0x18>,%d0:l),%d0
-  12:  4efb 0802       jmp %pc@(16 <f+0x16>,%d0:l)
+  12:  4efb 0804       jmp %pc@(18 <f+0x18>,%d0:l)
   16:  284c            moveal %a4,%a4
   18:  0000 0020       orib #32,%d0
   1c:  0000 002c       orib #44,%d0

Bootstrapped and tested on m68k-linux-gnu, no regressions.

Note: I don't have commit rights to I would need assistance applying this.

PR target/112413
gcc/

* config/m68k/linux.h (ASM_RETURN_CASE_JUMP): For
TARGET_LONG_JUMP_TABLE_OFFSETS, reference the jump table
via its label.
* config/m68k/m68kelf.h (ASM_RETURN_CASE_JUMP): Likewise.
* config/m68k/netbsd-elf.h (ASM_RETURN_CASE_JUMP): Likewise.

19 months agoaarch64: enable mixed-types for aarch64 simdclones
Andre Vieira [Mon, 11 Dec 2023 14:24:41 +0000 (14:24 +0000)] 
aarch64: enable mixed-types for aarch64 simdclones

This patch enables the use of mixed-types for simd clones for AArch64, adds
aarch64 as a target_vect_simd_clones and corrects the way the simdlen is chosen
for non-specified simdlen clauses according to the 'Vector Function Application
Binary Interface Specification for AArch64'.

Additionally this patch also restricts combinations of simdlen and
return/argument types that map to vectors larger than 128 bits as we currently
do not have a way to represent these types in a way that is consistent
internally and externally.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (lane_size): New function.
(aarch64_simd_clone_compute_vecsize_and_simdlen): Determine simdlen according to NDS rule
and reject combination of simdlen and types that lead to vectors larger than 128bits.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Add aarch64 targets to vect_simd_clones.
* c-c++-common/gomp/declare-variant-14.c: Adapt test for aarch64.
* c-c++-common/gomp/pr60823-1.c: Likewise.
* c-c++-common/gomp/pr60823-2.c: Likewise.
* c-c++-common/gomp/pr60823-3.c: Likewise.
* g++.dg/gomp/attrs-10.C: Likewise.
* g++.dg/gomp/declare-simd-1.C: Likewise.
* g++.dg/gomp/declare-simd-3.C: Likewise.
* g++.dg/gomp/declare-simd-4.C: Likewise.
* g++.dg/gomp/declare-simd-7.C: Likewise.
* g++.dg/gomp/declare-simd-8.C: Likewise.
* g++.dg/gomp/pr88182.C: Likewise.
* gcc.dg/declare-simd.c: Likewise.
* gcc.dg/gomp/declare-simd-1.c: Likewise.
* gcc.dg/gomp/declare-simd-3.c: Likewise.
* gcc.dg/gomp/pr87887-1.c: Likewise.
* gcc.dg/gomp/pr87895-1.c: Likewise.
* gcc.dg/gomp/pr89246-1.c: Likewise.
* gcc.dg/gomp/pr99542.c: Likewise.
* gcc.dg/gomp/simd-clones-2.c: Likewise.
* gcc.dg/vect/vect-simd-clone-1.c: Likewise.
* gcc.dg/vect/vect-simd-clone-2.c: Likewise.
* gcc.dg/vect/vect-simd-clone-4.c: Likewise.
* gcc.dg/vect/vect-simd-clone-5.c: Likewise.
* gcc.dg/vect/vect-simd-clone-6.c: Likewise.
* gcc.dg/vect/vect-simd-clone-7.c: Likewise.
* gcc.dg/vect/vect-simd-clone-8.c: Likewise.
* gfortran.dg/gomp/declare-simd-2.f90: Likewise.
* gfortran.dg/gomp/declare-simd-coarray-lib.f90: Likewise.
* gfortran.dg/gomp/declare-variant-14.f90: Likewise.
* gfortran.dg/gomp/pr79154-1.f90: Likewise.
* gfortran.dg/gomp/pr83977.f90: Likewise.

libgomp/ChangeLog:

* testsuite/libgomp.c/declare-variant-1.c: Adapt test for aarch64.
* testsuite/libgomp.fortran/declare-simd-1.f90: Likewise.

19 months agoc++: alias CTAD and specializations table
Patrick Palka [Mon, 11 Dec 2023 14:48:04 +0000 (09:48 -0500)] 
c++: alias CTAD and specializations table

A rewritten guide for alias CTAD isn't really a specialization of the
original guide, so we shouldn't register it as such.  This avoids an ICE
in the below modules testcase for which we otherwise crash due to the
guide's empty DECL_CONTEXT when walking the specializations table.  It
also preemptively avoids the same ICE in modules/concept-6 in C++23 mode
with the inherited CTAD patch.

gcc/cp/ChangeLog:

* pt.cc (alias_ctad_tweaks): Pass use_spec_table=false to
tsubst_decl.

gcc/testsuite/ChangeLog:

* g++.dg/modules/concept-8.h: New test.
* g++.dg/modules/concept-8_a.H: New test.
* g++.dg/modules/concept-8_b.C: New test.

19 months agoRISC-V: testsuite: Fix strcmp-run.c test.
Robin Dapp [Mon, 11 Dec 2023 13:16:04 +0000 (14:16 +0100)] 
RISC-V: testsuite: Fix strcmp-run.c test.

This fixes expectations in the strcmp-run test which would sometimes
fail with newlib.  The test expects libc strcmp return values and
asserts the vectorized result is similar to those.  Therefore hard-code
the expected results instead of relying on a strcmp call.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/builtin/strcmp-run.c: Adjust test
expectation and target selector.
* gcc.target/riscv/rvv/autovec/builtin/strlen-run.c: Adjust
target selector.
* gcc.target/riscv/rvv/autovec/builtin/strncmp-run.c: Ditto.

19 months agoOpenMP: Support acquires/release in 'omp require atomic_default_mem_order'
Tobias Burnus [Mon, 11 Dec 2023 14:19:02 +0000 (15:19 +0100)] 
OpenMP: Support acquires/release in 'omp require atomic_default_mem_order'

This is an OpenMP 5.2 feature.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_requires): Handle acquires/release
in atomic_default_mem_order clause.
(c_parser_omp_atomic): Update.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_requires): Handle acquires/release
in atomic_default_mem_order clause.
(cp_parser_omp_atomic): Update.

gcc/fortran/ChangeLog:

* gfortran.h (enum gfc_omp_requires_kind): Add
OMP_REQ_ATOMIC_MEM_ORDER_ACQUIRE and OMP_REQ_ATOMIC_MEM_ORDER_RELEASE.
(gfc_namespace): Add a 7th bit to omp_requires.
* module.cc (enum ab_attribute): Add AB_OMP_REQ_MEM_ORDER_ACQUIRE
and AB_OMP_REQ_MEM_ORDER_RELEASE
(mio_symbol_attribute): Handle it.
* openmp.cc (gfc_omp_requires_add_clause): Update for acquire/release.
(gfc_match_omp_requires): Likewise.
(gfc_match_omp_atomic): Handle them for atomic_default_mem_order.
* parse.cc: Likewise.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/requires-3.c: Update for now valid code.
* gfortran.dg/gomp/requires-3.f90: Likewise.
* gfortran.dg/gomp/requires-2.f90: Update dg-error.
* gfortran.dg/gomp/requires-5.f90: Likewise.
* c-c++-common/gomp/requires-5.c: New test.
* c-c++-common/gomp/requires-6.c: New test.
* c-c++-common/gomp/requires-7.c: New test.
* c-c++-common/gomp/requires-8.c: New test.
* gfortran.dg/gomp/requires-10.f90: New test.
* gfortran.dg/gomp/requires-11.f90: New test.

19 months agoOpenMP: Minor '!$omp allocators' cleanup
Tobias Burnus [Mon, 11 Dec 2023 14:08:07 +0000 (15:08 +0100)] 
OpenMP: Minor '!$omp allocators' cleanup

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_omp_call_add_alloc,
gfc_omp_call_is_alloc): Set 'fn spec'.

libgomp/ChangeLog:

* libgomp_g.h (GOMP_add_alloc, GOMP_is_alloc): Add.

19 months agoada: Fix Ada bootstrap on FreeBSD
Rainer Orth [Mon, 11 Dec 2023 12:38:19 +0000 (13:38 +0100)] 
ada: Fix Ada bootstrap on FreeBSD

Ada bootstrap on FreeBSD/amd64 was also broken by the recent warning
changes:

terminals.c: In function 'allocate_pty_desc':
terminals.c:1200:12: error: implicit declaration of function 'openpty'; did you
mean 'openat'? [-Wimplicit-function-declaration]
 1200 |   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
      |            ^~~~~~~
      |            openat

terminals.c: At top level:
terminals.c:1268:9: warning: "TABDLY" redefined
 1268 | #define TABDLY 0
      |         ^~~~~~
In file included from /usr/include/termios.h:38,
                 from terminals.c:1109:
/usr/include/sys/_termios.h:111:9: note: this is the location of the previous definition
  111 | #define TABDLY          0x00000004      /* tab delay mask */
      |         ^~~~~~
make[7]: *** [../gcc-interface/Makefile:302: terminals.o] Error 1

Fixed by including the necessary header and guarding the fallback
definition of TABDLY.

This allowed a 64-bit-only bootstrap on x86_64-unknown-freebsd14.0 to
complete successfully.

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

gcc/ada:
* terminals.c [__FreeBSD__]: Include <libutil.h>.
(TABDLY): Only define if missing.

19 months agoRTL-SSA: Fix ICE on record_use of RTL_SSA for RISC-V VSETVL PASS
Juzhe-Zhong [Mon, 11 Dec 2023 12:16:28 +0000 (20:16 +0800)] 
RTL-SSA: Fix ICE on record_use of RTL_SSA for RISC-V VSETVL PASS

This patch fixes an ICE on record_use during RTL_SSA initialization RISC-V backend VSETVL PASS.

This is the ICE:

0x11a8603 partial_subreg_p(machine_mode, machine_mode)
        ../../../../gcc/gcc/rtl.h:3187
0x3b695eb rtl_ssa::function_info::record_use(rtl_ssa::function_info::build_info&, rtl_ssa::insn_info*, rtx_obj_reference)
        ../../../../gcc/gcc/rtl-ssa/insns.cc:524

In record_use:

      if (HARD_REGISTER_NUM_P (regno)
  && partial_subreg_p (use->mode (), mode))

Assertion failed on partial_subreg_p which is:

inline bool
partial_subreg_p (machine_mode outermode, machine_mode innermode)
{
  /* Modes involved in a subreg must be ordered.  In particular, we must
     always know at compile time whether the subreg is paradoxical.  */
  poly_int64 outer_prec = GET_MODE_PRECISION (outermode);
  poly_int64 inner_prec = GET_MODE_PRECISION (innermode);
  gcc_checking_assert (ordered_p (outer_prec, inner_prec));                     -----> cause ICE.
  return maybe_lt (outer_prec, inner_prec);
}

RISC-V VSETVL PASS is an advanced lazy vsetvl insertion PASS after RA (register allocation).

The rootcause is that we have a pattern (reduction instruction) that includes both VLA (length-agnostic) and VLS (fixed-length) modes.

(insn 168 173 170 31 (set (reg:RVVM1SI 101 v5 [311])
        (unspec:RVVM1SI [
                (unspec:V32BI [
                        (const_vector:V32BI [
                                (const_int 1 [0x1]) repeated x32
                            ])
                        (reg:DI 30 t5 [312])
                        (const_int 2 [0x2]) repeated x2
                        (reg:SI 66 vl)
                        (reg:SI 67 vtype)
                    ] UNSPEC_VPREDICATE)
                (unspec:RVVM1SI [
                        (reg:V32SI 96 v0 [orig:185 vect__96.40 ] [185])   -----> VLS mode NUNITS = 32 elements.
                        (reg:RVVM1SI 113 v17 [439])                       -----> VLA mode NUNITS = [8, 8] elements.
                    ] UNSPEC_REDUC_XOR)
                (unspec:RVVM1SI [
                        (reg:SI 0 zero)
                    ] UNSPEC_VUNDEF)
            ] UNSPEC_REDUC)) 15948 {pred_redxorv32si}

In this case, record_use is trying to check partial_subreg_p (use->mode (), mode) for RTX = (reg:V32SI 96 v0 [orig:185 vect__96.40 ] [185]).

use->mode () == V32SImode, wheras mode = RVVM1SImode. Then it ICE since they are !ordered_p.

Set the use mode as the biggest mode which is natural fall back mode.

gcc/ChangeLog:

* rtl-ssa/insns.cc (function_info::record_use): Add !ordered_p case.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/vsetvl_bug-2.c: New test.

19 months agoRISC-V: Robostify shuffle index used by vrgather and fix regression
Juzhe-Zhong [Mon, 11 Dec 2023 11:58:43 +0000 (19:58 +0800)] 
RISC-V: Robostify shuffle index used by vrgather and fix regression

Notice there are some regression FAILs:
FAIL: gcc.target/riscv/rvv/autovec/pr110950.c -O3 -ftree-vectorize  scan-assembler-times vslide1up\\.vx 1
FAIL: gcc.target/riscv/rvv/autovec/vls-vlmax/perm-4.c -std=c99 -O3 -ftree-vectorize --param riscv-autovec-preference=fixed-vlmax  scan-assembler-times vrgather\\.vv\\tv[0-9]+,\\s*v[0-9]+,\\s*v[0-9]+ 19
FAIL: gcc.target/riscv/rvv/autovec/vls-vlmax/perm-4.c -std=c99 -O3 -ftree-vectorize --param riscv-autovec-preference=fixed-vlmax  scan-assembler-times vrgatherei16\\.vv\\tv[0-9]+,\\s*v[0-9]+,\\s*v[0-9]+ 12
FAIL: gcc.target/riscv/rvv/autovec/vls/perm-4.c -O3 -ftree-vectorize --param riscv-autovec-preference=scalable  scan-assembler-times vrgather\\.vv\\tv[0-9]+,\\s*v[0-9]+,\\s*v[0-9]+ 19
FAIL: gcc.target/riscv/rvv/autovec/vls/perm-4.c -O3 -ftree-vectorize --param riscv-autovec-preference=scalable  scan-assembler-times vrgatherei16\\.vv\\tv[0-9]+,\\s*v[0-9]+,\\s*v[0-9]+ 12

pr110950 is not a regression, adapt testcase is enough.

The rest FAILs which is caused by this patch:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d9dd06ad51b7479f09acb88adf404664a1e18b2a

need to be recovered back.

Robostify the gather index to fixe those FAILs.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (get_gather_index_mode): New function.
(shuffle_series_patterns): Robostify shuffle index.
(shuffle_generic_patterns): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr110950.c: Adapt test.

19 months agoTestsuite, asan, darwin: Adjust output pattern
Francois-Xavier Coudert [Mon, 11 Dec 2023 08:40:03 +0000 (09:40 +0100)] 
Testsuite, asan, darwin: Adjust output pattern

Since the last import from upstream libsanitizer, the output has changed
and now looks more like this:

READ of size 6 at 0x7ff7beb2a144 thread T0
    #0 0x101cf7796 in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) sanitizer_common_interceptors.inc:813
    #1 0x101cf7b99 in memcmp sanitizer_common_interceptors.inc:840
    #2 0x108a0c39f in __stack_chk_guard+0xf (dyld:x86_64+0x8039f)

so let's adjust the pattern accordingly.

gcc/testsuite/ChangeLog:

* c-c++-common/asan/memcmp-1.c: Adjust pattern on darwin.

19 months agoaarch64: arm_neon.h - Fix -Wincompatible-pointer-types errors
Victor Do Nascimento [Fri, 8 Dec 2023 16:37:31 +0000 (16:37 +0000)] 
aarch64: arm_neon.h - Fix -Wincompatible-pointer-types errors

In the Linux kernel, u64/s64 are [un]signed long long, not [un]signed
long.  This means that when the `arm_neon.h' header is used by the
kernel, any use of the `uint64_t' / `in64_t' types needs to be
correctly cast to the correct `__builtin_aarch64_simd_di' /
`__builtin_aarch64_simd_df' types when calling the relevant ACLE
builtins.

This patch adds the necessary fixes to ensure that `vstl1_*' and
`vldap1_*' intrinsics are correctly defined for use by the kernel.

gcc/ChangeLog:

* config/aarch64/arm_neon.h (vldap1_lane_u64): Add
`const' to `__builtin_aarch64_simd_di *' cast.
(vldap1q_lane_u64): Likewise.
(vldap1_lane_s64): Cast __src to `const __builtin_aarch64_simd_di *'.
(vldap1q_lane_s64): Likewise.
(vldap1_lane_f64): Cast __src to `const __builtin_aarch64_simd_df *'.
(vldap1q_lane_f64): Cast __src to `const __builtin_aarch64_simd_df *'.
(vldap1_lane_p64): Add `const' to `__builtin_aarch64_simd_di *' cast.
(vldap1q_lane_p64): Add `const' to `__builtin_aarch64_simd_di *' cast.
(vstl1_lane_u64): remove stray `const'.
(vstl1_lane_s64): Cast __src to `__builtin_aarch64_simd_di *'.
(vstl1q_lane_s64): Likewise.
(vstl1_lane_f64): Cast __src to `const __builtin_aarch64_simd_df *'.
(vstl1q_lane_f64): Likewise.

19 months agod: Merge upstream dmd, druntime 2bbf64907c, phobos b64bfbf91
Iain Buclaw [Thu, 7 Dec 2023 10:55:12 +0000 (11:55 +0100)] 
d: Merge upstream dmd, druntime 2bbf64907c, phobos b64bfbf91

D front-end changes:

    - Import dmd v2.106.0.

D runtime changes:

    - Import druntime v2.106.0.

Phobos changes:

    - Import phobos v2.106.0.

gcc/d/ChangeLog:

* Make-lang.in (D_FRONTEND_OBJS): Rename d/common-string.o to
d/common-smallbuffer.o.
* dmd/MERGE: Merge upstream dmd 2bbf64907c.
* dmd/VERSION: Bump version to v2.106.0.
* modules.cc (layout_moduleinfo_fields): Update for new front-end
interface.
(layout_moduleinfo): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 2bbf64907c.
* src/MERGE: Merge upstream phobos b64bfbf91.

19 months agoRISC-V: Rename test[NFC]
Juzhe-Zhong [Mon, 11 Dec 2023 09:44:24 +0000 (17:44 +0800)] 
RISC-V: Rename test[NFC]

Since I want to commit multiple tests which are fixing vsetvl bugs,
rename it to make testcases more easier maintain.

Committed as it is obvious.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/avl_use_bug-1.c: Moved to...
* gcc.target/riscv/rvv/vsetvl/vsetvl_bug-1.c: ...here.

19 months agoRISC-V: Recognize stepped series in expand_vec_perm_const.
Robin Dapp [Fri, 8 Dec 2023 11:50:01 +0000 (12:50 +0100)] 
RISC-V: Recognize stepped series in expand_vec_perm_const.

We currently try to recognize various forms of stepped (const_vector)
sequence variants in expand_const_vector.  Because of complications with
canonicalization and encoding it is easier to identify such patterns
in expand_vec_perm_const_1 already where perm.series_p () is available.

This patch introduces shuffle_series as new permutation pattern and
tries to recognize series like [base0 base1 base1 + step ...].  If such
a series is found the series is expanded by expand_vec_series and a
gather is emitted.

On top the patch fixes the step recognition in expand_const_vector
for stepped series where such a series would end up before.

This fixes several execution failures when running code compiled for a
scalable vector size of 128 on a target with vlen = 256 or higher.
The problem was only noticed there because the encoding for a reversed
[2 2]-element vector ("3 2 1 0") is { [1 2], [0 2], [1 4] }.

Some testcases that failed were:
vect-alias-check-18.c
vect-alias-check-1.F90
pr64365.c

On a 128-bit target, only the first two elements are used.  The
third element causing the complications only comes into effect at
vlen = 256.

With this patch the testsuite results are similar with vlen = 128,
vlen = 256 as well as vlen = 512 (apart from the fixed-vlmax tests of
course).

gcc/ChangeLog:

PR target/112853

* config/riscv/riscv-v.cc (expand_const_vector):  Fix step
calculation.
(modulo_sel_indices): Also perform modulo for variable-length
constants.
(shuffle_series): Recognize series permutations.
(expand_vec_perm_const_1): Add shuffle_series.

19 months agoTestsuite, i386: mark test as requiring dfp
Francois-Xavier Coudert [Mon, 11 Dec 2023 08:33:47 +0000 (09:33 +0100)] 
Testsuite, i386: mark test as requiring dfp

Test currently fails on darwin with:
error: decimal floating-point not supported for this target

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr112445.c: Require dfp.

19 months agoSimplify vector ((VCE (a cmp b ? -1 : 0)) < 0) ? c : d to just (VCE ((a cmp b) ?...
liuhongt [Thu, 9 Nov 2023 08:03:11 +0000 (16:03 +0800)] 
Simplify vector ((VCE (a cmp b ? -1 : 0)) < 0) ? c : d to just (VCE ((a cmp b) ? (VCE c) : (VCE d))).

When I'm working on PR112443, I notice there's some misoptimizations:
after we fold _mm{,256}_blendv_epi8/pd/ps into gimple, the backend
fails to combine it back to v{,p}blendv{v,ps,pd} since the pattern is
too complicated, so I think maybe we should hanlde it in the gimple
level.

The dump is like

  _1 = c_3(D) >= { 0, 0, 0, 0 };
  _2 = VEC_COND_EXPR <_1, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }>;
  _7 = VIEW_CONVERT_EXPR<vector(32) char>(_2);
  _8 = VIEW_CONVERT_EXPR<vector(32) char>(b_6(D));
  _9 = VIEW_CONVERT_EXPR<vector(32) char>(a_5(D));
  _10 = _7 < { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  _11 = VEC_COND_EXPR <_10, _8, _9>;

It can be optimized to

  _1 = c_2(D) >= { 0, 0, 0, 0 };
  _6 = VEC_COND_EXPR <_1, b_5(D), a_4(D)>;

since _7 is either -1 or 0, the selection of _7 < 0 ? _8 : _9 should
be euqal to _1 ? b : a as long as TYPE_PRECISION of the component type
of the second VEC_COND_EXPR is less equal to the first one.
The patch add a gimple pattern to handle that.

gcc/ChangeLog:

* match.pd (VCE (a cmp b ? -1 : 0) < 0) ? c : d ---> (VCE ((a
cmp b) ? (VCE:c) : (VCE:d))): New gimple simplication.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512vl-blendv-3.c: New test.
* gcc.target/i386/blendv-3.c: New test.

19 months agoTestsuite, Darwin: actually skip test
Francois-Xavier Coudert [Mon, 11 Dec 2023 08:20:49 +0000 (09:20 +0100)] 
Testsuite, Darwin: actually skip test

Previous commit xfailed instead of skipping, but we really
want to skip.

gcc/testsuite/ChangeLog:

* gcc.target/i386/libcall-1.c: Skip on darwin.

19 months agoRISC-V: Support highest overlap for wv instructions
Juzhe-Zhong [Sat, 9 Dec 2023 04:06:29 +0000 (12:06 +0800)] 
RISC-V: Support highest overlap for wv instructions

According to RVV ISA, we can allow vwadd.wv v2, v2, v3 overlap.

Before this patch:

        nop
        vsetivli        zero,4,e8,m4,tu,ma
        vle16.v v8,0(a0)
        vmv8r.v v0,v8
        vwsub.wv        v0,v8,v12
        nop
        addi    a4,a0,100
        vle16.v v8,0(a4)
        vmv8r.v v24,v8
        vwsub.wv        v24,v8,v12
        nop
        addi    a4,a0,200
        vle16.v v8,0(a4)
        vmv8r.v v16,v8
        vwsub.wv        v16,v8,v12
        nop

After this patch:

nop
vsetivli zero,4,e8,m4,tu,ma
vle16.v v0,0(a0)
vwsub.wv v0,v0,v4
nop
addi a4,a0,100
vle16.v v24,0(a4)
vwsub.wv v24,v24,v28
nop
addi a4,a0,200
vle16.v v16,0(a4)
vwsub.wv v16,v16,v20

PR target/112431

gcc/ChangeLog:

* config/riscv/vector.md: Support highest overlap for wv instructions.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr112431-39.c: New test.
* gcc.target/riscv/rvv/base/pr112431-40.c: New test.
* gcc.target/riscv/rvv/base/pr112431-41.c: New test.

19 months agoRISC-V: Fix ICE in extract_single_source
Juzhe-Zhong [Mon, 11 Dec 2023 06:43:34 +0000 (14:43 +0800)] 
RISC-V: Fix ICE in extract_single_source

This patch fixes the following ICE in VSETVL PASS:
bug.c:39:1: internal compiler error: Segmentation fault
   39 | }
      | ^
0x1ad5a08 crash_signal
        ../../../../gcc/gcc/toplev.cc:316
0x7f7f55feb90f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x218d7c7 extract_single_source
        ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:583
0x218d95d extract_single_source
        ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:604
0x218fbc5 pre_vsetvl::compute_lcm_local_properties()
        ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:2703
0x2190ef4 pre_vsetvl::earliest_fuse_vsetvl_info()
        ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:2890
0x2193e62 pass_vsetvl::lazy_vsetvl()
        ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:3537
0x219406a pass_vsetvl::execute(function*)
        ../../../../gcc/gcc/config/riscv/riscv-vsetvl.cc:3584

The rootcause we have a case that the def info can not be traced:

(insn 208 327 333 27 (use (reg/i:DI 10 a0)) "bug.c":36:1 -1
     (nil))

It's obvious, we conservatively disable any optimization in this situation if
AVL def_info can not be tracded.

Committed as it is obvious.

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (extract_single_source): Fix ICE.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/avl_use_bug-1.c: New test.

19 months agoextend.texi: Mark builtin arguments with @var{...}
Jakub Jelinek [Mon, 11 Dec 2023 07:34:15 +0000 (08:34 +0100)] 
extend.texi: Mark builtin arguments with @var{...}

In many cases we just specify types for the builtin arguments, in other cases
types and names with @var{name} syntax, and in other case with just name.

Shall we tweak that somehow?  If the argument names are unimportant, perhaps
it is fine to leave that out, but shouldn't we always use @var{...} around
the parameter names when specified?

On Fri, Dec 01, 2023 at 10:43:57AM -0700, Sandra Loosemore wrote:
> Yup.  The Texinfo manual says:  "When using @deftypefn command and
> variations, you should mark parameter names with @var to distinguish these
> from data type names, keywords, and other parts of the literal syntax of the
> programming language."

Here is a patch which does that (but not adding types to where they were
missing, that will be harder to search for).

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

* doc/extend.texi (__sync_fetch_and_add, __sync_fetch_and_sub,
__sync_fetch_and_or, __sync_fetch_and_and, __sync_fetch_and_xor,
__sync_fetch_and_nand, __sync_add_and_fetch, __sync_sub_and_fetch,
__sync_or_and_fetch, __sync_and_and_fetch, __sync_xor_and_fetch,
__sync_nand_and_fetch, __sync_bool_compare_and_swap,
__sync_val_compare_and_swap, __sync_lock_test_and_set,
__sync_lock_release, __atomic_load_n, __atomic_load, __atomic_store_n,
__atomic_store, __atomic_exchange_n, __atomic_exchange,
__atomic_compare_exchange_n, __atomic_compare_exchange,
__atomic_add_fetch, __atomic_sub_fetch, __atomic_and_fetch,
__atomic_xor_fetch, __atomic_or_fetch, __atomic_nand_fetch,
__atomic_fetch_add, __atomic_fetch_sub, __atomic_fetch_and,
__atomic_fetch_xor, __atomic_fetch_or, __atomic_fetch_nand,
__atomic_test_and_set, __atomic_clear, __atomic_thread_fence,
__atomic_signal_fence, __atomic_always_lock_free,
__atomic_is_lock_free, __builtin_add_overflow,
__builtin_sadd_overflow, __builtin_saddl_overflow,
__builtin_saddll_overflow, __builtin_uadd_overflow,
__builtin_uaddl_overflow, __builtin_uaddll_overflow,
__builtin_sub_overflow, __builtin_ssub_overflow,
__builtin_ssubl_overflow, __builtin_ssubll_overflow,
__builtin_usub_overflow, __builtin_usubl_overflow,
__builtin_usubll_overflow, __builtin_mul_overflow,
__builtin_smul_overflow, __builtin_smull_overflow,
__builtin_smulll_overflow, __builtin_umul_overflow,
__builtin_umull_overflow, __builtin_umulll_overflow,
__builtin_add_overflow_p, __builtin_sub_overflow_p,
__builtin_mul_overflow_p, __builtin_addc, __builtin_addcl,
__builtin_addcll, __builtin_subc, __builtin_subcl, __builtin_subcll,
__builtin_alloca, __builtin_alloca_with_align,
__builtin_alloca_with_align_and_max, __builtin_speculation_safe_value,
__builtin_nan, __builtin_nand32, __builtin_nand64, __builtin_nand128,
__builtin_nanf, __builtin_nanl, __builtin_nanf@var{n},
__builtin_nanf@var{n}x, __builtin_nans, __builtin_nansd32,
__builtin_nansd64, __builtin_nansd128, __builtin_nansf,
__builtin_nansl, __builtin_nansf@var{n}, __builtin_nansf@var{n}x,
__builtin_ffs, __builtin_clz, __builtin_ctz, __builtin_clrsb,
__builtin_popcount, __builtin_parity, __builtin_bswap16,
__builtin_bswap32, __builtin_bswap64, __builtin_bswap128,
__builtin_extend_pointer, __builtin_goacc_parlevel_id,
__builtin_goacc_parlevel_size, vec_clrl, vec_clrr, vec_mulh, vec_mul,
vec_div, vec_dive, vec_mod, __builtin_rx_mvtc): Use @var{...} around
parameter names.
(vec_rl, vec_sl, vec_sr, vec_sra): Likewise.  Use @var{...} also
around A, B and R in description.

19 months agoRISC-V: Remove poly selftest when --preference=fixed-vlmax
Juzhe-Zhong [Mon, 11 Dec 2023 03:00:14 +0000 (11:00 +0800)] 
RISC-V: Remove poly selftest when --preference=fixed-vlmax

This patch fixes multiple ICEs in full coverage testing:

cc1: internal compiler error: in riscv_legitimize_poly_move, at config/riscv/riscv.cc:2456^M
0x1fd8d78 riscv_legitimize_poly_move^M
        ../../../../gcc/gcc/config/riscv/riscv.cc:2456^M
0x1fd9518 riscv_legitimize_move(machine_mode, rtx_def*, rtx_def*)^M
        ../../../../gcc/gcc/config/riscv/riscv.cc:2583^M
0x2936820 gen_movdi(rtx_def*, rtx_def*)^M
        ../../../../gcc/gcc/config/riscv/riscv.md:2099^M
0x11a0f28 rtx_insn* insn_gen_fn::operator()<rtx_def*, rtx_def*>(rtx_def*, rtx_def*) const^M
        ../../../../gcc/gcc/recog.h:431^M
0x13cf2f9 emit_move_insn_1(rtx_def*, rtx_def*)^M
        ../../../../gcc/gcc/expr.cc:4553^M
0x13d010c emit_move_insn(rtx_def*, rtx_def*)^M
        ../../../../gcc/gcc/expr.cc:4723^M
0x216f5e0 run_poly_int_selftest^M
        ../../../../gcc/gcc/config/riscv/riscv-selftests.cc:185^M
0x21701e6 run_poly_int_selftests^M
        ../../../../gcc/gcc/config/riscv/riscv-selftests.cc:226^M
0x2172109 selftest::riscv_run_selftests()^M
        ../../../../gcc/gcc/config/riscv/riscv-selftests.cc:371^M
0x3b8067b selftest::run_tests()^M
        ../../../../gcc/gcc/selftest-run-tests.cc:112^M
0x1ad90ee toplev::run_self_tests()^M
        ../../../../gcc/gcc/toplev.cc:2209^M

Running target riscv-sim/-march=rv64gcv/-mabi=lp64d/-mcmodel=medlow/--param=riscv-autovec-lmul=m1/--param=riscv-autovec-preference=fixed-vlmax

The rootcause is that we are testing POLY value computation during FIXED-VLMAX and ICE in this code:

  if (BYTES_PER_RISCV_VECTOR.is_constant ())
    {
      gcc_assert (value.is_constant ());                           ----->  assert failed.
      riscv_emit_move (dest, GEN_INT (value.to_constant ()));
      return;
    }

For example, a poly value [15, 16] is computed by csrr vlen + multiple scalar integer instructions.

However, such compile-time unknown value need to be computed when it is scalable vector, that is !BYTES_PER_RISCV_VECTOR.is_constant (),
since csrr vlenb = [16, 0] when -march=rv64gcv --param=riscv-autovec-preference=fixed-vlmax and we have no chance to compute compile-time POLY value.

Also, we never reach the situation to compute a compile time unknown value when it is FIXED-VLMAX vector. So disable POLY selftest for FIXED-VLMAX.

gcc/ChangeLog:

* config/riscv/riscv-selftests.cc (riscv_run_selftests):
Remove poly self test when FIXED-VLMAX.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/poly-selftest-1.c: New test.

19 months ago[PATCH 3/5] [ifcvt] optimize x=c ? (y AND z) : y by RISC-V Zicond like insns
Fei Gao [Mon, 11 Dec 2023 05:21:58 +0000 (22:21 -0700)] 
[PATCH 3/5] [ifcvt] optimize x=c ? (y AND z) : y by RISC-V Zicond like insns

Take the following case for example.

CFLAGS: -march=rv64gc_zbb_zicond -mabi=lp64d -O2

long
test_AND_ceqz (long x, long y, long z, long c)
{
  if (c)
    x = y & z;
  else
    x = y;
  return x;
}

Before patch:

and a2,a1,a2
czero.eqz a0,a2,a3
czero.nez a3,a1,a3
or a0,a3,a0
ret

After patch:
and a0,a1,a2
czero.nez a1,a1,a3
or a0,a1,a0
ret

Co-authored-by: Xiao Zeng<zengxiao@eswincomputing.com>
gcc/ChangeLog:

* ifcvt.cc (noce_cond_zero_binary_op_supported): Add support for AND.
(noce_bbs_ok_for_cond_zero_arith): Likewise.
(noce_try_cond_zero_arith): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zicond_ifcvt_opt.c: Add TCs for AND.

19 months agoc++: Fix noexcept checking for trivial operations [PR96090]
Nathaniel Shead [Sat, 28 Oct 2023 05:04:52 +0000 (16:04 +1100)] 
c++: Fix noexcept checking for trivial operations [PR96090]

This patch stops eager folding of trivial operations (construction and
assignment) from occurring when checking for noexceptness. This was
previously done in PR c++/53025, but only for copy/move construction,
and the __is_nothrow_xible builtins did not receive the same treatment
when they were added.

To handle `is_nothrow_default_constructible`, the patch also ensures
that when no parameters are passed we do value initialisation instead of
just building the constructor call: in particular, value-initialisation
doesn't necessarily actually invoke the constructor for trivial default
constructors, and so we need to handle this case as well.

This is contrary to the proposed resolution of CWG2820; for now we just
ensure it matches the behaviour of the `noexcept` operator and create
testcases formalising this, and if that issue gets accepted we can
revisit.

PR c++/96090
PR c++/100470

gcc/cp/ChangeLog:

* call.cc (build_over_call): Prevent folding of trivial special
members when checking for noexcept.
* method.cc (constructible_expr): Perform value-initialisation
for empty parameter lists.
(is_nothrow_xible): Treat as noexcept operator.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept81.C: New test.
* g++.dg/ext/is_nothrow_constructible7.C: New test.
* g++.dg/ext/is_nothrow_constructible8.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
19 months agoc++: Clear uninstantiated template friend when instantiating [PR104234]
Nathaniel Shead [Thu, 23 Nov 2023 12:15:19 +0000 (23:15 +1100)] 
c++: Clear uninstantiated template friend when instantiating [PR104234]

Otherwise attempting to get the originating module declaration ICEs
because the DECL_CHAIN of an instantiated friend template is no longer
its context.

PR c++/104234
PR c++/112580

gcc/cp/ChangeLog:

* pt.cc (tsubst_template_decl): Clear
DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr104234.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
19 months agoSupport vpcmov for V4HF/V4BF/V2HF/V2BF under TARGET_XOP.
liuhongt [Fri, 8 Dec 2023 03:19:52 +0000 (11:19 +0800)] 
Support vpcmov for V4HF/V4BF/V2HF/V2BF under TARGET_XOP.

gcc/ChangeLog:

PR target/112904
* config/i386/mmx.md (*xop_pcmov_<mode>): New define_insn.

gcc/testsuite/ChangeLog:

* g++.target/i386/pr112904.C: New test.

19 months agors6000: Guard fctid on PowerPC64 and PowerPC476
Haochen Gui [Mon, 11 Dec 2023 00:41:55 +0000 (08:41 +0800)] 
rs6000: Guard fctid on PowerPC64 and PowerPC476

fctid is only supported on 64-bit Power processors and powerpc 476. It
should be guarded by this condition. The patch fixes the issue.

gcc/
PR target/112707
* config/rs6000/rs6000.h (TARGET_FCTID): Define.
* config/rs6000/rs6000.md (lrint<mode>di2): Add guard TARGET_FCTID.
* (lround<mode>di2): Replace TARGET_FPRND with TARGET_FCTID.

gcc/testsuite/
PR target/112707
* gcc.target/powerpc/pr112707.h: New.
* gcc.target/powerpc/pr112707-2.c: New.
* gcc.target/powerpc/pr112707-3.c: New.
* gcc.target/powerpc/pr88558-p7.c: Check fctid on ilp32 and
has_arch_ppc64 as it's now guarded by powerpc64.
* gcc.target/powerpc/pr88558-p8.c: Likewise.
* gfortran.dg/nint_p7.f90: Add powerpc64 target requirement as
lround<mode>di2 is now guarded by powerpc64.

19 months agors6000: Enable lrint<mode>si2 on old archs with stfiwx enabled
Haochen Gui [Mon, 11 Dec 2023 00:40:34 +0000 (08:40 +0800)] 
rs6000: Enable lrint<mode>si2 on old archs with stfiwx enabled

The powerpc 32-bit processors (e.g. 5470) supports "fctiw" instruction,
but the instruction can't be generated on such platforms as the insn is
guard by TARGET_POPCNTD.  The root cause is SImode in float register is
supported from Power7.  Actually implementation of "fctiw" only needs
stfiwx which is supported by the old 32-bit processors.  This patch
enables "fctiw" expand for these processors.

gcc/
PR target/112707
* config/rs6000/rs6000.md (expand lrint<mode>si2): New.
(insn lrint<mode>si2): Rename to...
(*lrint<mode>si): ...this.
(lrint<mode>si_di): New.

gcc/testsuite/
PR target/112707
* gcc.target/powerpc/pr112707-1.c: New.

19 months agoDaily bump.
GCC Administrator [Mon, 11 Dec 2023 00:17:32 +0000 (00:17 +0000)] 
Daily bump.

19 months agoAdd some new DW_IDX_* constants
Tom Tromey [Sat, 9 Dec 2023 16:19:30 +0000 (09:19 -0700)] 
Add some new DW_IDX_* constants

I've reimplemented the .debug_names code in GDB -- it was quite far
from being correct, and the new implementation is much closer to what
is specified by DWARF.

However, the new writer in GDB needs to emit some symbol properties,
so that the reader can be fully functional.  This patch adds a few new
DW_IDX_* constants, and tries to document the existing extensions as
well.  (My patch series add more documentation of these to the GDB
manual as well.)

include/ChangeLog
2023-12-10  Tom Tromey  <tom@tromey.com>

* dwarf2.def (DW_IDX_GNU_internal, DW_IDX_GNU_external): Comment.
(DW_IDX_GNU_main, DW_IDX_GNU_language, DW_IDX_GNU_linkage_name):
New constants.

19 months ago[PATCH 2/5] [ifcvt] optimize x=c ? (y shift_op z):y by RISC-V Zicond like insns
Fei Gao [Sun, 10 Dec 2023 20:39:30 +0000 (13:39 -0700)] 
[PATCH 2/5] [ifcvt] optimize x=c ? (y shift_op z):y by RISC-V Zicond like insns

op=[ASHIFT, ASHIFTRT, LSHIFTRT, ROTATE, ROTATERT]

Conditional op, if zero
rd = (rc == 0) ? (rs1 op rs2) : rs1
-->
czero.nez rd, rs2, rc
op rd, rs1, rd

Conditional op, if non-zero
rd = (rc != 0) ? (rs1 op rs2) : rs1
-->
czero.eqz rd, rs2, rc
op rd, rs1, rd

gcc/ChangeLog:

* ifcvt.cc (noce_cond_zero_binary_op_supported): Add support for shift
like op.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zicond_ifcvt_opt.c: Add tests for shift like op.

Co-authored-by: Xiao Zeng<zengxiao@eswincomputing.com>
19 months agoaarch64: Fix invalid subregs for BE svread/write_za
Richard Sandiford [Sun, 10 Dec 2023 19:46:07 +0000 (19:46 +0000)] 
aarch64: Fix invalid subregs for BE svread/write_za

Multi-register svread_za and svwrite_za are implemented using one
pattern per register count, with the register contents being bitcast
on entry (for writes) or return (for reads).  Previously we relied
on subregs for this, with the subreg for reads being handled by
target-independent code.  But using subregs isn't correct for many
big-endian cases, where following subreg rules often requires actual
instructions.  The semantics are instead supposed to be those of
svreinterpret.

gcc/
PR target/112931
PR target/112933
* config/aarch64/aarch64-protos.h (aarch64_sve_reinterpret): Declare.
* config/aarch64/aarch64.cc (aarch64_sve_reinterpret): New function.
* config/aarch64/aarch64-sve-builtins-sme.cc (svread_za_impl::expand)
(svwrite_za_impl::expand): Use it to cast the SVE register to the
right mode.

19 months agoaarch64: Fix SMSTART/SMSTOP save/restore for BE
Richard Sandiford [Sun, 10 Dec 2023 19:46:06 +0000 (19:46 +0000)] 
aarch64: Fix SMSTART/SMSTOP save/restore for BE

VNx16QI (the SVE register byte mode) is the only SVE mode for which
LD1 and LDR result in the same register layout for big-endian.  It is
therefore the only mode for which we allow LDR and STR to be used for
big-endian SVE moves.

The SME support sometimes needs to use LDR and STR to save and restore
Z register contents around an SMSTART/SMSTOP SM.  It therefore needs
to use VNx16QI regardless of the type of value that is stored in the
Z registers.

gcc/
PR target/112930
* config/aarch64/aarch64.cc (aarch64_sme_mode_switch_regs::add_reg):
Force specific SVE modes for single registers as well as structures.

19 months agoaarch64: XFAIL some SME tests for BE
Richard Sandiford [Sun, 10 Dec 2023 19:46:05 +0000 (19:46 +0000)] 
aarch64: XFAIL some SME tests for BE

The z0_z23 tests rely on being able to propagate:

  (1) set of double-register z0-z1
  (2) copy of z0 to z28
  (3) use of z28

to a use of z0.  On LE targets it's regcprop that does this.
But regcprop punts on (2) because of:

  https://gcc.gnu.org/pipermail/gcc-patches/2002-July/081990.html

This patch therefore XFAILs the affected tests.

gcc/testsuite/
* gcc.target/aarch64/sme2/acle-asm/uzp_bf16_x2.c: XFAIL z0_z23 tests
for big-endian.
* gcc.target/aarch64/sme2/acle-asm/uzp_f16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_f32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_f64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_s16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_s32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_s64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_s8_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_u16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_u32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_u64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzp_u8_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_bf16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_f16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_f32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_f64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_s16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_s32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_s64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_s8_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_u16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_u32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_u64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/uzpq_u8_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_bf16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_f16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_f32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_f64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_s16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_s32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_s64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_s8_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_u16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_u32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_u64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zip_u8_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_bf16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_f16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_f32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_f64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_s16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_s32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_s64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_s8_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_u16_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_u32_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_u64_x2.c: Likewise.
* gcc.target/aarch64/sme2/acle-asm/zipq_u8_x2.c: Likewise.

19 months agoaarch64: Skip some SME register save tests on BE
Richard Sandiford [Sun, 10 Dec 2023 19:46:05 +0000 (19:46 +0000)] 
aarch64: Skip some SME register save tests on BE

Big-endian targets need to save Z8-Z15 in the same order as
the registers would appear for D8-D15, because the layout is
mandated by the EH ABI.  BE targets therefore use ST1D instead
of the normal STR for those registers (but not for others).

That difference is already tested elsewhere and isn't important
for the SME tests.  This patch therefore restricts the affected
tests to LE.

gcc/testsuite/
* gcc.target/aarch64/sme/call_sm_switch_5.c: Restrict tests that
contain Z8-Z23 saves to little-endian.
* gcc.target/aarch64/sme/call_sm_switch_8.c: Likewise.
* gcc.target/aarch64/sme/locally_streaming_1.c: Likewise.

19 months agoaarch64: Add -funwind-tables to some tests
Richard Sandiford [Sun, 10 Dec 2023 19:46:05 +0000 (19:46 +0000)] 
aarch64: Add -funwind-tables to some tests

The .cfi scans in these tests failed for *-elf targets because
those targets don't enable .eh_frame info by default.

gcc/testsuite/
* gcc.target/aarch64/sme/call_sm_switch_1.c: Add -funwind-tables.
* gcc.target/aarch64/sme/call_sm_switch_3.c: Likewise.
* gcc.target/aarch64/sme/call_sm_switch_5.c: Likewise.

19 months agoFortran: allow NULL() for POINTER, OPTIONAL, CONTIGUOUS dummy [PR111503]
Harald Anlauf [Fri, 8 Dec 2023 12:57:31 +0000 (13:57 +0100)] 
Fortran: allow NULL() for POINTER, OPTIONAL, CONTIGUOUS dummy [PR111503]

gcc/fortran/ChangeLog:

PR fortran/111503
* expr.cc (gfc_is_simply_contiguous): Determine characteristics of
NULL() from optional MOLD argument, otherwise treat as contiguous.
* primary.cc (gfc_variable_attr): Derive attributes of NULL(MOLD)
from MOLD.

gcc/testsuite/ChangeLog:

PR fortran/111503
* gfortran.dg/contiguous_14.f90: New test.

19 months agoFortran: function returning contiguous class array [PR105543]
Harald Anlauf [Wed, 6 Dec 2023 19:42:27 +0000 (20:42 +0100)] 
Fortran: function returning contiguous class array [PR105543]

gcc/fortran/ChangeLog:

PR fortran/105543
* resolve.cc (resolve_symbol): For a CLASS-valued function having a
RESULT clause, ensure that attr.class_ok is set for its symbol as
well as for its resolved result variable.

gcc/testsuite/ChangeLog:

PR fortran/105543
* gfortran.dg/contiguous_13.f90: New test.

19 months agodoc: small tweak
Jason Merrill [Sun, 10 Dec 2023 19:20:32 +0000 (14:20 -0500)] 
doc: small tweak

Mention Objective-C++ here to be consistent with the surrounding C/ObjC
lines.

gcc/ChangeLog:

* doc/invoke.texi (-fpermissive): Mention ObjC++ for -Wnarrowing.

19 months agoc++: Implement __remove_pointer built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:17 +0000 (21:33 -0800)] 
c++: Implement __remove_pointer built-in trait

This patch implements built-in trait for std::remove_pointer.

gcc/cp/ChangeLog:

* cp-trait.def: Define __remove_pointer.
* semantics.cc (finish_trait_type): Handle CPTK_REMOVE_POINTER.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of __remove_pointer.
* g++.dg/ext/remove_pointer.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_object built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:15 +0000 (21:33 -0800)] 
c++: Implement __is_object built-in trait

This patch implements built-in trait for std::is_object.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_object.
* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_OBJECT.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of __is_object.
* g++.dg/ext/is_object.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_function built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:13 +0000 (21:33 -0800)] 
c++: Implement __is_function built-in trait

This patch implements built-in trait for std::is_function.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_function.
* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_FUNCTION.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of __is_function.
* g++.dg/ext/is_function.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_reference built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:11 +0000 (21:33 -0800)] 
c++: Implement __is_reference built-in trait

This patch implements built-in trait for std::is_reference.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_reference.
* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_REFERENCE.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of __is_reference.
* g++.dg/ext/is_reference.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_member_object_pointer built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:09 +0000 (21:33 -0800)] 
c++: Implement __is_member_object_pointer built-in trait

This patch implements built-in trait for std::is_member_object_pointer.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_member_object_pointer.
* constraint.cc (diagnose_trait_expr): Handle
CPTK_IS_MEMBER_OBJECT_POINTER.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of
__is_member_object_pointer.
* g++.dg/ext/is_member_object_pointer.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_member_function_pointer built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:07 +0000 (21:33 -0800)] 
c++: Implement __is_member_function_pointer built-in trait

This patch implements built-in trait for std::is_member_function_pointer.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_member_function_pointer.
* constraint.cc (diagnose_trait_expr): Handle
CPTK_IS_MEMBER_FUNCTION_POINTER.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of
__is_member_function_pointer.
* g++.dg/ext/is_member_function_pointer.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_member_pointer built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:05 +0000 (21:33 -0800)] 
c++: Implement __is_member_pointer built-in trait

This patch implements built-in trait for std::is_member_pointer.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_member_pointer.
* constraint.cc (diagnose_trait_expr): Handle
CPTK_IS_MEMBER_POINTER.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of
__is_member_pointer.
* g++.dg/ext/is_member_pointer.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_scoped_enum built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:03 +0000 (21:33 -0800)] 
c++: Implement __is_scoped_enum built-in trait

This patch implements built-in trait for std::is_scoped_enum.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_scoped_enum.
* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_SCOPED_ENUM.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of __is_scoped_enum.
* g++.dg/ext/is_scoped_enum.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_bounded_array built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:33:01 +0000 (21:33 -0800)] 
c++: Implement __is_bounded_array built-in trait

This patch implements built-in trait for std::is_bounded_array.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_bounded_array.
* constraint.cc (diagnose_trait_expr): Handle
CPTK_IS_BOUNDED_ARRAY.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of
__is_bounded_array.
* g++.dg/ext/is_bounded_array.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Implement __is_array built-in trait
Ken Matsui [Thu, 7 Dec 2023 05:32:59 +0000 (21:32 -0800)] 
c++: Implement __is_array built-in trait

This patch implements built-in trait for std::is_array.

gcc/cp/ChangeLog:

* cp-trait.def: Define __is_array.
* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_ARRAY.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Test existence of __is_array.
* g++.dg/ext/is_array.C: New test.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: trait patch tweak
Jason Merrill [Fri, 8 Dec 2023 20:55:49 +0000 (15:55 -0500)] 
c++: trait patch tweak

As Patrick suggested elsewhere, let's move this into the default case.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_simple_type_specifier): Move trait
handling to default label.

19 months agoc++: Accept the use of built-in trait identifiers
Ken Matsui [Thu, 7 Dec 2023 05:32:58 +0000 (21:32 -0800)] 
c++: Accept the use of built-in trait identifiers

This patch accepts the use of built-in trait identifiers when they are
actually not used as traits.  Specifically, we check if the subsequent
token is '(' for ordinary built-in traits or is '<' only for the special
__type_pack_element built-in trait.  If those identifiers are used
differently, the parser treats them as normal identifiers.  This allows
us to accept code like: struct __is_pointer {};.

gcc/cp/ChangeLog:

* parser.cc (cp_lexer_lookup_trait): Rename to ...
(cp_lexer_peek_trait): ... this.  Handle a subsequent token for
the corresponding built-in trait.
(cp_lexer_lookup_trait_expr): Rename to ...
(cp_lexer_peek_trait_expr): ... this.
(cp_lexer_lookup_trait_type): Rename to ...
(cp_lexer_peek_trait_type): ... this.
(cp_lexer_next_token_is_decl_specifier_keyword): Call
cp_lexer_peek_trait_type.
(cp_parser_simple_type_specifier): Likewise.
(cp_parser_primary_expression): Call cp_lexer_peek_trait_expr.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc-family, c++: Look up built-in traits via identifier node
Ken Matsui [Thu, 7 Dec 2023 05:32:57 +0000 (21:32 -0800)] 
c-family, c++: Look up built-in traits via identifier node

Since RID_MAX soon reaches 255 and all built-in traits are used
approximately once in a C++ translation unit, this patch removes
all RID values for built-in traits and uses the identifier node to
look up the specific trait.  Rather than holding traits as keywords,
we set all trait identifiers as cik_trait, which is a new
cp_identifier_kind.  As cik_reserved_for_udlit was unused and
cp_identifier_kind is 3 bits, we replaced the unused field with the new
cik_trait.  Also, the later patch handles a subsequent token to the
built-in identifier so that we accept the use of non-function-like
built-in trait identifiers.

gcc/c-family/ChangeLog:

* c-common.cc (c_common_reswords): Remove all mappings of
built-in traits.
* c-common.h (enum rid): Remove all RID values for built-in
traits.

gcc/cp/ChangeLog:

* cp-objcp-common.cc (names_builtin_p): Remove all RID value
cases for built-in traits.  Check for built-in traits via
the new cik_trait kind.
* cp-tree.h (enum cp_trait_kind): Set its underlying type to
addr_space_t.
(struct cp_trait): New struct to hold trait information.
(cp_traits): New array to hold a mapping to all traits.
(cik_reserved_for_udlit): Rename to ...
(cik_trait): ... this.
(IDENTIFIER_ANY_OP_P): Exclude cik_trait.
(IDENTIFIER_TRAIT_P): New macro to detect cik_trait.
* lex.cc (cp_traits): Define its values, declared in cp-tree.h.
(init_cp_traits): New function to set cik_trait and
IDENTIFIER_CP_INDEX for all built-in trait identifiers.
(cxx_init): Call init_cp_traits function.
* parser.cc (cp_lexer_lookup_trait): New function to look up a
built-in trait by IDENTIFIER_CP_INDEX.
(cp_lexer_lookup_trait_expr): Likewise, look up an
expression-yielding built-in trait.
(cp_lexer_lookup_trait_type): Likewise, look up a type-yielding
built-in trait.
(cp_keyword_starts_decl_specifier_p): Remove all RID value cases
for built-in traits.
(cp_lexer_next_token_is_decl_specifier_keyword): Handle
type-yielding built-in traits.
(cp_parser_primary_expression): Remove all RID value cases for
built-in traits.  Handle expression-yielding built-in traits.
(cp_parser_trait): Handle cp_trait instead of enum rid.
(cp_parser_simple_type_specifier): Remove all RID value cases
for built-in traits.  Handle type-yielding built-in traits.

Co-authored-by: Patrick Palka <ppalka@redhat.com>
Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months agoc++: Sort built-in traits alphabetically
Ken Matsui [Thu, 7 Dec 2023 05:32:56 +0000 (21:32 -0800)] 
c++: Sort built-in traits alphabetically

This patch sorts built-in traits alphabetically for better code
readability.

gcc/cp/ChangeLog:

* constraint.cc (diagnose_trait_expr): Sort built-in traits
alphabetically.
* cp-trait.def: Likewise.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.
(finish_trait_type): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/has-builtin-1.C: Sort built-in traits alphabetically.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
19 months ago[committed] Support uaddv and usubv on the H8
Jeff Law [Sun, 10 Dec 2023 17:41:05 +0000 (10:41 -0700)] 
[committed] Support uaddv and usubv on the H8

This patch adds uaddv/usubv support on the H8 port to speed up those pesky
builtin-overflow tests.  It's a variant of something I'd been running for a
while -- the major change between the old approach I'd been using and this
patch is this version does not expose the CC register until after reload to be
consistent with the rest of the H8 port.

The general approach is to first clear the GPR that's going to hold the
overflow status, perform the arithmetic operation (add/sub), then use addx to
move the overflow indicator (in the C bit) into the GPR holding the overflow
status.

That's a significant improvement over the mess of logicals that's generated by
the generic code.

Handling signed overflow is possible and something I'll probably port to this
scheme at some point.  It's a bit more complex because we can't trivially move
the bit from CCR into the right position in a GPR and other quirks of the H8.

This has been regression tested on the H8 without problems.  Pushing to the
trunk.

gcc/
* config/h8300/addsub.md (uaddv<mode>4, usubv<mode>4): New expanders.
(uaddv): New define_insn_and_split plus post-reload pattern.

19 months ago[committed] Provide patterns for signed bitfield extractions on H8
Jeff Law [Sun, 10 Dec 2023 17:29:23 +0000 (10:29 -0700)] 
[committed] Provide patterns for signed bitfield extractions on H8

Inspired by Roger's work on the ARC port, this patch provides a
define_and_split pattern to optimize sign extended bitfields starting at
position 0 using an approach that doesn't require shifting.

It then builds on that to provide another define_and_split pattern to support
arbitrary signed bitfield extractions -- it uses a right logical shift to move
the bitfield into position 0, then the specialized pattern above to sign extend
the MSB of the field through the rest of the register.

This is often, but certainly not always, better than a two shift approach.  The
code uses the sizes of the sequences to select between the two shift approach
and single shift with extension from an arbitrary location approach.

There's certainly further improvements that could be made here, but I think
we're getting the bulk of the improvements already.

Regression tested on the H8 port without errors.  Installing on the trunk.

gcc/
* config/h8300/h8300-protos.h (use_extvsi): Prototype.
* config/h8300/combiner.md: Two new define_insn_and_split patterns
to implement signed bitfield extractions.
* config/h8300/h8300.cc (use_extvsi): New function.

19 months ago[committed] Fix length computation of single bit bitfield extraction on H8
Jeff Law [Sun, 10 Dec 2023 17:05:18 +0000 (10:05 -0700)] 
[committed] Fix length computation of single bit bitfield extraction on H8

Various approaches are used to optimize extracting a sign extended single bit
bitfield.  The length computation of 10 bytes was conservatively correct, but
inaccurate.

In particular when the bit we want is in the low half word we don't need the
move high half to low half instruction.  Account for that in the length
computation.

This was spotted when looking at regressions in the generalized signed bitfield
extraction pattern.

This has been regression tested on the H8 port.

gcc/
* config/h8300/combiner.md (single bit signed bitfield extraction): Fix
length computation when the bit we want is in the low half word.

19 months ago[committed] Fix length computation for logical shifts on H8
Jeff Law [Sun, 10 Dec 2023 16:32:55 +0000 (09:32 -0700)] 
[committed] Fix length computation for logical shifts on H8

This fixes the length computation for logical shifts on the H8/SX.

The H8/SX has a richer set of logical shifts compared to early parts in the H8
family.  It has special 2 byte instructions for shifts by power of two
immediate values as well as a special 4 byte shift by other immediate values.

These were never accounted for (AFIACT) in the length computation for shifts.
Until now that's mostly just affected branch shortening.  But an upcoming patch
uses instruction lengths to select between two potential sequences and getting
these lengths wrong will cause it to miss optimization opportunities on the
H8/SX.

gcc
* config/h8300/h8300.cc (compute_a_shift_length): Fix computation
of logical shifts on the H8/SX.

19 months agoDaily bump.
GCC Administrator [Sun, 10 Dec 2023 00:16:47 +0000 (00:16 +0000)] 
Daily bump.

19 months agophiopt: Fix ICE with large --param l1-cache-line-size= [PR112887]
Jakub Jelinek [Sat, 9 Dec 2023 20:41:00 +0000 (21:41 +0100)] 
phiopt: Fix ICE with large --param l1-cache-line-size= [PR112887]

This function is never called when param_l1_cache_line_size is 0,
but it uses int and unsigned int variables to hold alignment in
bits, so for large param_l1_cache_line_size it is zero and e.g.
DECL_ALIGN () % param_align_bits can divide by zero.
Looking at the code, the function uses tree_fits_uhwi_p on the trees
before converting them using tree_to_uhwi to int variables, which
looks just wrong, either it would need to punt if it doesn't fit
into those and also check for overflows during the computation,
or use unsigned HOST_WIDE_INT for all of this.  That also fixes
the division by zero, as param_l1_cache_line_size maximum is INT_MAX,
that multiplied by 8 will always fit.

2023-12-09  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/112887
* tree-ssa-phiopt.cc (hoist_adjacent_loads): Change type of
param_align, param_align_bits, offset1, offset2, size2 and align1
variables from int or unsigned int to unsigned HOST_WIDE_INT.

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

19 months agotestsuite: Add testcase for already fixed PR [PR112924]
Jakub Jelinek [Sat, 9 Dec 2023 14:29:51 +0000 (15:29 +0100)] 
testsuite: Add testcase for already fixed PR [PR112924]

This testcase got fixed with
r14-6132-g50f2a3370d177f8fe9bea0461feb710523e048a2 .
I'm just adding a testcase so that it doesn't reappear.

2023-12-09  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/112924
* gcc.dg/pr112924.c: New test.

19 months agolibstdc++: Fix value of __cpp_lib_format macro [PR111826]
Jonathan Wakely [Fri, 8 Dec 2023 14:40:26 +0000 (14:40 +0000)] 
libstdc++: Fix value of __cpp_lib_format macro [PR111826]

As noted in the PR, we support both features required for the 202110L
value, so we should define it with that value.

libstdc++-v3/ChangeLog:

PR libstdc++/111826
* include/bits/version.def (format): Update value.
* include/bits/version.h: Regenerate.
* testsuite/std/format/functions/format.cc:

19 months agolibstdc++: Fix resolution of LWG 4016 for std::ranges::to [PR112876]
Jonathan Wakely [Fri, 8 Dec 2023 13:47:04 +0000 (13:47 +0000)] 
libstdc++: Fix resolution of LWG 4016 for std::ranges::to [PR112876]

What I implemented in r14-6199-g45630fbcf7875b does not match what I
proposed for LWG 4016, and it imposes additional, unwanted requirements
on the emplace and insert member functions of the container being
populated.

libstdc++-v3/ChangeLog:

PR libstdc++/112876
* include/std/ranges (ranges::to): Do not try to use an iterator
returned by the container's emplace or insert member functions.
* testsuite/std/ranges/conv/1.cc (Cont4::emplace, Cont4::insert):
Use the iterator parameter. Do not return an iterator.

19 months agodriver: Fix memory leak [PR93019]
Jakub Jelinek [Sat, 9 Dec 2023 09:28:37 +0000 (10:28 +0100)] 
driver: Fix memory leak [PR93019]

driver:finalize used by JIT clears the mdswitches pointer; if it was
allocated before, that leaks the memory.

2023-12-09  Costas Argyris  <costas.argyris@gmail.com>
    Jakub Jelinek  <jakub@redhat.com>

PR driver/93019
* gcc.cc (driver::finalize): Call XDELETEVEC on mdswitches before
clearing it.

Signed-off-by: Costas Argyris <costas.argyris@gmail.com>
19 months agoc++: Don't diagnose ignoring of attributes if all ignored attributes are attribute_ig...
Jakub Jelinek [Sat, 9 Dec 2023 09:20:05 +0000 (10:20 +0100)] 
c++: Don't diagnose ignoring of attributes if all ignored attributes are attribute_ignored_p

There is another thing I wonder about: with -Wno-attributes= we are
supposed to ignore the attributes altogether, but we are actually still
warning about them when we emit these generic warnings about ignoring
all attributes which appertain to this and that (perhaps with some
exceptions we first remove from the attribute chain), like:
void foo () { [[foo::bar]]; }
with -Wattributes -Wno-attributes=foo::bar
Shouldn't we call some helper function in cases like this and warn
not when std_attrs (or how the attribute chain var is called) is non-NULL,
but if it is non-NULL and contains at least one non-attribute_ignored_p
attribute?

I've kept warnings for cases where the C++ standard says explicitly any
attributes aren't ok -
"If an attribute-specifier-seq appertains to a friend declaration, that
declaration shall be a definition."
or
https://eel.is/c++draft/dcl.type.elab#3
or
https://eel.is/c++draft/temp.spec#temp.explicit-3

For some changes I haven't figured out how could I cover it in the
testsuite.

Note, C uses a different strategy, it has c_warn_unused_attributes
function which warns about all the attributes one by one unless they
are ignored (or allowed in certain position).
Though that is just a single diagnostic wording, while C++ FE just warns
that there are some ignored attributes and doesn't name them individually
(except for namespace and using namespace) and uses different wordings in
different spots.

2023-12-09  Jakub Jelinek  <jakub@redhat.com>

gcc/
* attribs.h (any_nonignored_attribute_p): Declare.
* attribs.cc (any_nonignored_attribute_p): New function.
gcc/cp/
* parser.cc (cp_parser_statement, cp_parser_expression_statement,
cp_parser_declaration, cp_parser_asm_definition): Don't diagnose
ignored attributes if !any_nonignored_attribute_p.
* decl.cc (grokdeclarator): Likewise.
* name-lookup.cc (handle_namespace_attrs, finish_using_directive):
Don't diagnose ignoring of attr_ignored_p attributes.
gcc/testsuite/
* g++.dg/warn/Wno-attributes-1.C: New test.

19 months agoRISC-V: Fix VLS mode movmiaslign bug
Juzhe-Zhong [Sat, 9 Dec 2023 08:31:53 +0000 (16:31 +0800)] 
RISC-V: Fix VLS mode movmiaslign bug

PR112932 let me notice there is a bug of current VLS mode misalign pattern.
Adapt it same as VLA mode.

Commited as it is obvious fix.

PR target/112932

gcc/ChangeLog:

* config/riscv/vector.md (movmisalign<mode>): Fix VLSmode bugs.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/misalign-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/pr112932.c: New test.

19 months agotestsuite: Remove gcc.dg/tree-ssa/scev-3.c -4.c and 5.c
Hans-Peter Nilsson [Thu, 7 Dec 2023 16:23:30 +0000 (17:23 +0100)] 
testsuite: Remove gcc.dg/tree-ssa/scev-3.c -4.c and 5.c

These tests were recently xfailed on ilp32 targets though
passing on almost all ilp32 targets (known exceptions: ia32
and some arm subtargets).  They've been changed around too
much to remain useful.

PR testsuite/112786
* gcc.dg/tree-ssa/scev-3.c, gcc.dg/tree-ssa/scev-4.c,
gcc.dg/tree-ssa/scev-5.c: Remove.

19 months agostrub: skip emutls after strubm errors
Alexandre Oliva [Sat, 9 Dec 2023 00:41:33 +0000 (21:41 -0300)] 
strub: skip emutls after strubm errors

The emutls pass requires PROP_ssa, but if the strubm pass (or any
other pre-SSA pass) issues errors, all of the build_ssa_passes are
skipped, so the property is not set, but emutls still attempts to run,
on targets that use it, despite earlier errors, so it hits the
unsatisfied requirement.

Adjust emutls to be skipped in case of earlier errors.

for  gcc/ChangeLog

* tree-emutls.cc: Include diagnostic-core.h.
(pass_ipa_lower_emutls::gate): Skip if errors were seen.

19 months agoDaily bump.
GCC Administrator [Sat, 9 Dec 2023 00:17:30 +0000 (00:17 +0000)] 
Daily bump.