aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-09-02i386: Optimize generate insn for AVX10.2 compareHu, Lin15-2/+147
gcc/ChangeLog: * config/i386/i386-expand.cc (ix86_expand_fp_compare): Add UNSPEC to support the optimization. * config/i386/i386.cc (ix86_fp_compare_code_to_integer): Add NE/EQ. * config/i386/i386.md (*cmpx<unord><MODEF:mode>): New define_insn. (*cmpx<unord>hf): Ditto. * config/i386/predicates.md (ix86_trivial_fp_comparison_operator): Add ne/eq. gcc/testsuite/ChangeLog: * gcc.target/i386/avx10_2-compare-1b.c: New test.
2024-09-02i386: Optimize ordered and nonequalHu, Lin12-0/+12
Currently, when we input !__builtin_isunordered (a, b) && (a != b), gcc will emit ucomiss %xmm1, %xmm0 movl $1, %ecx setp %dl setnp %al cmovne %ecx, %edx andl %edx, %eax movzbl %al, %eax In fact, xorl %eax, %eax ucomiss %xmm1, %xmm0 setne %al is better. gcc/ChangeLog: * match.pd: Optimize (and ordered non-equal) to (not (or unordered equal)) gcc/testsuite/ChangeLog: * gcc.target/i386/optimize_one.c: New test.
2024-09-02i386: Auto vectorize sdot_prod, usdot_prod, udot_prod with AVX10.2 instructionsHaochen Jiang7-78/+86
gcc/ChangeLog: * config/i386/sse.md (VI1_AVX512VNNIBW): New. (VI2_AVX10_2): Ditto. (sdot_prod<mode>): Add AVX10.2 to auto vectorize and combine 512 bit part. (udot_prod<mode>): Ditto. (sdot_prodv64qi): Removed. (udot_prodv64qi): Ditto. (usdot_prod<mode>): Add AVX10.2 to auto vectorize. (udot_prod<mode>): Ditto. gcc/testsuite/ChangeLog: * gcc.target/i386/vnniint16-auto-vectorize-2.c: Only define TEST when not defined. * gcc.target/i386/vnniint8-auto-vectorize-2.c: Ditto. * gcc.target/i386/vnniint16-auto-vectorize-3.c: New test. * gcc.target/i386/vnniint16-auto-vectorize-4.c: Ditto. * gcc.target/i386/vnniint8-auto-vectorize-3.c: Ditto. * gcc.target/i386/vnniint8-auto-vectorize-4.c: Ditto.
2024-09-02RISC-V: Add testcases for unsigned scalar quad and oct .SAT_TRUNC form 3Pan Li6-0/+102
This patch would like to add test cases for the unsigned scalar quad and oct .SAT_TRUNC form 3. Aka: Form 3: #define DEF_SAT_U_TRUC_FMT_3(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_3 (WT x) \ { \ WT max = (WT)(NT)-1; \ return x <= max ? (NT)x : (NT) max; \ } QUAD: DEF_SAT_U_TRUC_FMT_3 (uint16_t, uint64_t) DEF_SAT_U_TRUC_FMT_3 (uint8_t, uint32_t) OCT: DEF_SAT_U_TRUC_FMT_3 (uint8_t, uint64_t) The below test is passed for this patch. * The rv64gcv regression test. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat_u_trunc-16.c: New test. * gcc.target/riscv/sat_u_trunc-17.c: New test. * gcc.target/riscv/sat_u_trunc-18.c: New test. * gcc.target/riscv/sat_u_trunc-run-16.c: New test. * gcc.target/riscv/sat_u_trunc-run-17.c: New test. * gcc.target/riscv/sat_u_trunc-run-18.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-09-02RISC-V: Add testcases for unsigned scalar quad and oct .SAT_TRUNC form 2Pan Li6-0/+102
This patch would like to add test cases for the unsigned scalar quad and oct .SAT_TRUNC form 2. Aka: Form 2: #define DEF_SAT_U_TRUC_FMT_2(NT, WT) \ NT __attribute__((noinline)) \ sat_u_truc_##WT##_to_##NT##_fmt_2 (WT x) \ { \ WT max = (WT)(NT)-1; \ return x > max ? (NT) max : (NT)x; \ } QUAD: DEF_SAT_U_TRUC_FMT_2 (uint16_t, uint64_t) DEF_SAT_U_TRUC_FMT_2 (uint8_t, uint32_t) OCT: DEF_SAT_U_TRUC_FMT_2 (uint8_t, uint64_t) The below test is passed for this patch. * The rv64gcv regression test. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat_u_trunc-10.c: New test. * gcc.target/riscv/sat_u_trunc-11.c: New test. * gcc.target/riscv/sat_u_trunc-12.c: New test. * gcc.target/riscv/sat_u_trunc-run-10.c: New test. * gcc.target/riscv/sat_u_trunc-run-11.c: New test. * gcc.target/riscv/sat_u_trunc-run-12.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-09-02RISC-V: Add testcases for form 4 of unsigned vector .SAT_ADD IMMPan Li9-0/+188
This patch would like to add test cases for the unsigned vector .SAT_ADD when one of the operand is IMM. Form 4: #define DEF_VEC_SAT_U_ADD_IMM_FMT_4(T, IMM) \ T __attribute__((noinline)) \ vec_sat_u_add_imm##IMM##_##T##_fmt_4 (T *out, T *in, unsigned limit) \ { \ unsigned i; \ T ret; \ for (i = 0; i < limit; i++) \ { \ out[i] = __builtin_add_overflow (in[i], IMM, &ret) == 0 ? ret : -1; \ } \ } DEF_VEC_SAT_U_ADD_IMM_FMT_4(uint64_t, 123) The below test are passed for this patch. * The rv64gcv fully regression test. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vec_sat_arith.h: Add test helper macros. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-13.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-14.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-15.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-16.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-13.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-14.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-15.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-16.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-09-02RISC-V: Add testcases for form 3 of unsigned vector .SAT_ADD IMMPan Li8-0/+168
This patch would like to add test cases for the unsigned vector .SAT_ADD when one of the operand is IMM. Form 3: #define DEF_VEC_SAT_U_ADD_IMM_FMT_3(T, IMM) \ T __attribute__((noinline)) \ vec_sat_u_add_imm##IMM##_##T##_fmt_3 (T *out, T *in, unsigned limit) \ { \ unsigned i; \ T ret; \ for (i = 0; i < limit; i++) \ { \ out[i] = __builtin_add_overflow (in[i], IMM, &ret) ? -1 : ret; \ } \ } DEF_VEC_SAT_U_ADD_IMM_FMT_3(uint64_t, 123) The below test are passed for this patch. * The rv64gcv fully regression test. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-10.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-11.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-12.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-9.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-10.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-11.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-12.c: New test. * gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm-run-9.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-09-02RISC-V: Refactor gen zero_extend rtx for SAT_* when expand SImode in RV64Pan Li25-53/+118
In previous, we have some specially handling for both the .SAT_ADD and .SAT_SUB for unsigned int. There are similar to take care of SImode in RV64 for zero extend. Thus refactor these two helper function into one for possible code duplication. The below test suite are passed for this patch. * The rv64gcv fully regression test. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_gen_zero_extend_rtx): Merge the zero_extend handing from func riscv_gen_unsigned_xmode_reg. (riscv_gen_unsigned_xmode_reg): Remove. (riscv_expand_ussub): Leverage riscv_gen_zero_extend_rtx instead of riscv_gen_unsigned_xmode_reg. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat_u_sub-11.c: Adjust asm check. * gcc.target/riscv/sat_u_sub-15.c: Ditto. * gcc.target/riscv/sat_u_sub-19.c: Ditto. * gcc.target/riscv/sat_u_sub-23.c: Ditto. * gcc.target/riscv/sat_u_sub-27.c: Ditto. * gcc.target/riscv/sat_u_sub-3.c: Ditto. * gcc.target/riscv/sat_u_sub-31.c: Ditto. * gcc.target/riscv/sat_u_sub-35.c: Ditto. * gcc.target/riscv/sat_u_sub-39.c: Ditto. * gcc.target/riscv/sat_u_sub-43.c: Ditto. * gcc.target/riscv/sat_u_sub-47.c: Ditto. * gcc.target/riscv/sat_u_sub-7.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-11.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-11_1.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-11_2.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-15.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-15_1.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-15_2.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-3.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-3_1.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-3_2.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-7.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-7_1.c: Ditto. * gcc.target/riscv/sat_u_sub_imm-7_2.c: Ditto. Signed-off-by: Pan Li <pan2.li@intel.com>
2024-09-02Daily bump.GCC Administrator3-1/+27
2024-08-31slsr: Use simple_dce_from_worklist in SLSR [PR116554]Andrew Pinski1-18/+41
While working on a phiopt patch, it was noticed that SLSR would leave around some unused ssa names. Let's add simple_dce_from_worklist usage to SLSR to remove the dead statements. This should give a small improvemnent for passes afterwards. Boostrapped and tested on x86_64. gcc/ChangeLog: PR tree-optimization/116554 * gimple-ssa-strength-reduction.cc: Include tree-ssa-dce.h. (replace_mult_candidate): Add sdce_worklist argument, mark the rhs1/rhs2 for maybe dceing. (replace_unconditional_candidate): Add sdce_worklist argument, Update call to replace_mult_candidate. (replace_conditional_candidate): Add sdce_worklist argument, update call to replace_mult_candidate. (replace_uncond_cands_and_profitable_phis): Add sdce_worklist argument, update call to replace_conditional_candidate, replace_unconditional_candidate, and replace_uncond_cands_and_profitable_phis. (replace_one_candidate): Add sdce_worklist argument, mark the orig_rhs1/orig_rhs2 for maybe dceing. (replace_profitable_candidates): Add sdce_worklist argument, update call to replace_one_candidate and replace_profitable_candidates. (analyze_candidates_and_replace): Call simple_dce_from_worklist and update calls to replace_profitable_candidates, and replace_uncond_cands_and_profitable_phis. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-09-01testsuite: Prune compilation messages for modules testsHans-Peter Nilsson1-0/+10
All testsuite compiler-calls pass default_target_compile in the dejagnu installation (typically /usr/share/dejagnu/target.exp) which also calls the dejagnu-installed prune_warnings. Normally, tests using the dg framework (most or all tests these days) compile and link by calling various wrappers that end up calling dg-test in the dejagnu installation, typically installed as /usr/share/dejagnu/dg.exp. That, besides the compiler call, also calls ${tool}-dg-prune (g++-dg-prune) on the messages, which in turn ends up calling prune_gcc_output in gcc/testsuite/lib/prune.exp. That gcc-specific "pruning" function handles more cases than the dejagnu prune_warnings, and also has updated patterns. But, module_do_it in modules.exp calls the lower-level ${tool}_target_compile "directly", i.e. g++_target_compile defined in gcc/testsuite/lib/g++.exp. That does not call ${tool}-dg-prune, meaning those test-cases miss the gcc-specific pruning. Noticed while testing a dejagnu update that handled the miniscule "in" in the warning (line-breaks added below besides the original one after "(void*)':") "/path/to/cris-elf/bin/ld: /gccobj/cris-elf/./libstdc++-v3/src/.libs/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)': /gccsrc/libstdc++-v3/src/c++11/random.cc:183: warning: _getentropy is not implemented and will always fail" The line saying "in function" rather than "In function" (from the binutils linker since 2018) is pruned by prune_gcc_output. The prune_warnings in dejagnu-1.6.3 and earlier handles the second line separately. It's an unfortunate wart that neither consumes the delimiting line-break, leaving to the callers to prune residual empty lines. See prune_warnings in dejagnu (default_target_compile and dg-test) for those other line-break fixups, as alluded in the comment. * g++.dg/modules/modules.exp (module_do_it): Prune compilation messages.
2024-09-01Daily bump.GCC Administrator8-1/+188
2024-08-31i386: Support read-modify-write memory operands in STV.Roger Sayle3-3/+16
This patch enables STV when the first operand of a TImode binary logic operand (AND, IOR or XOR) is a memory operand, which is commonly the case with read-modify-write instructions. A different motivating example from the one given previously is: __int128 m, p, q; void foo() { m ^= (p & q); } Currently with -O2 -mavx the RMW instructions are rejected by STV, resulting in scalar code: foo: movq p(%rip), %rax movq p+8(%rip), %rdx andq q(%rip), %rax andq q+8(%rip), %rdx xorq %rax, m(%rip) xorq %rdx, m+8(%rip) ret With this patch they become scalar-to-vector candidates: foo: vmovdqa p(%rip), %xmm0 vpand q(%rip), %xmm0, %xmm0 vpxor m(%rip), %xmm0, %xmm0 vmovdqa %xmm0, m(%rip) ret 2024-08-31 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386-features.cc (timode_scalar_to_vector_candidate_p): Support the first operand of AND, IOR and XOR being MEM_P, i.e. a read-modify-write insn. gcc/testsuite/ChangeLog * gcc.target/i386/movti-2.c: Change dg-options to -Os. * gcc.target/i386/movti-4.c: Expected output of original movti-2.c.
2024-08-31libobjc: Add cast to void* to disable warning for casting between ↵Andrew Pinski1-3/+3
incompatible function types [PR89586] Even though __objc_get_forward_imp returns an IMP type, it will be casted to a compatable function type before calling it. So we adding a cast to `void*` will disable warning about the incompatible type. Pushed after bootstrap/test on x86_64. libobjc/ChangeLog: PR libobjc/89586 * sendmsg.c (__objc_get_forward_imp): Add cast to `void*` before casting to IMP. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-08-31AVR: Run pass avr-fuse-add a second time after pass_cprop_hardreg.Georg-Johann Lay2-0/+28
gcc/ * config/avr/avr-passes.cc (avr_pass_fuse_add) <clone>: Override. * config/avr/avr-passes.def (avr_pass_fuse_add): Run again after pass_cprop_hardreg.
2024-08-31AVR: Tidy pass avr-fuse-add.Georg-Johann Lay4-43/+12
gcc/ * config/avr/avr-protos.h (avr_split_tiny_move): Rename to avr_split_fake_addressing_move. * config/avr/avr-passes.def: Same. * config/avr/avr-passes.cc: Same. (avr_pass_data_fuse_add) <tv_id>: Set to TV_MACH_DEP. * config/avr/avr.md (split-lpmx): Remove a define_split. Such splits are performed by avr_split_fake_addressing_move.
2024-08-31testsuite, c++, coroutines: Avoid 'unused' warnings [NFC].Iain Sandoe6-7/+7
The 'torture' section of the coroutine tests is primarily about checking correct operation of the generated code. It should, ideally, be possible to run this part of the testsuite with '-Wall' and expect no fails. In the case that we wish to test for a specific diagnostic (and that it does not appear over a range of optimisation/debug conditions) then we should make that explict (as done, for example, in pr109867.C). The tests amended here have warnings because of unused entities; in many cases those are relevant to the test, and so we just mark them with __attribute__((__unused__)). We amend the debug output in coro.h to avoid similar warnings when print output is disabled (the default). gcc/testsuite/ChangeLog: * g++.dg/coroutines/coro.h: Use a variadic macro for PRINTF to avoid unused warnings when output is disabled. * g++.dg/coroutines/torture/co-await-04-control-flow.C: Avoid unused warnings. * g++.dg/coroutines/torture/co-ret-13-template-2.C: Likewise. * g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C: Likewise. * g++.dg/coroutines/torture/local-var-04-hiding-nested-scopes.C: Likewise. * g++.dg/coroutines/torture/pr109867.C: Likewise. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-31testsuite, c++, coroutines: Correct a test intent.Iain Sandoe1-8/+7
The intention of the series of tests numberef pr95615-* is to verify that entities created by the ramp and potentially needing destruction are correctly handled when exceptions are thrown. Because of a typo, one case was not being checked correctly (the return object). This patch amends the check to test that the returned object is properly deleted. gcc/testsuite/ChangeLog: * g++.dg/coroutines/torture/pr95615.inc: Check tha the task object produced by get_return_object is correctly deleted on exception. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-31c++, coroutines: Make and use a frame access helper.Iain Sandoe1-47/+44
In the review of earlier patches it was suggested that we might make use of finish_class_access_expr instead of doing a lookup for the member and then a build_class_access_expr call. finish_class_access_expr does a lot more work than we need and ends up calling build_class_access_expr anyway. So, instead, this patch makes a new helper to do the lookup and build and uses that helper everywhere except instances in the ramp function that we are going to handle separately. gcc/cp/ChangeLog: * coroutines.cc (coro_build_frame_access_expr): New. (transform_await_expr): Use coro_build_frame_access_expr. (transform_local_var_uses): Likewise. (build_actor_fn): Likewise. (build_destroy_fn): Likewise. (cp_coroutine_transform::build_ramp_function): Likewise. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-08-31hppa: Enable PA 2.0 symbolic operands on ELF32 targetsJohn David Anglin3-27/+25
The GNU ELF32 linker has been fixed and it can now handle PA 2.0 symbolic relocations. This only affects non-pic code generation. 2024-08-31 John David Anglin <danglin@gcc.gnu.org> gcc/ChangeLog: * config/pa/pa.cc (pa_emit_move_sequence): Remove symbolic memory work arounds for TARGET_ELF32. (pa_legitimate_address_p): Likewise. Allow symbolic operands. Adjust comment. * config/pa/pa.md: Replace reg_or_0_or_nonsymb_mem_operand with reg_or_0_or_mem_operand predicate in various unnamed move insns. * config/pa/predicates.md (floating_point_store_memory_operand): Update comment. Remove symbolic memory work arounds for TARGET_ELF32. (nonsymb_mem_operand): Rename to mem_operand. Allow symbolic memory operands. (reg_or_0_or_nonsymb_mem_operand): Rename to reg_or_0_or_mem_operand. Allow symbolic memory operands.
2024-08-31phiopt: Ignore some nop statements in heursics [PR116098]Andrew Pinski3-2/+119
The heurstics that was added for PR71016, try to search to see if the conversion was being moved away from its definition. The problem is the heurstics would stop if there was a non GIMPLE_ASSIGN (and already ignores debug statements) and in this case we would have a GIMPLE_LABEL that was not being ignored. So we should need to ignore GIMPLE_NOP, GIMPLE_LABEL and GIMPLE_PREDICT. Note this is now similar to how gimple_empty_block_p behaves. Note this fixes the wrong code that was reported by moving the VCE (conversion) out before the phiopt/match could convert it into an bit_ior and move the VCE out with the VCE being conditionally valid. Bootstrapped and tested on x86_64-linux-gnu. Also built and tested for aarch64-linux-gnu. PR tree-optimization/116098 gcc/ChangeLog: * tree-ssa-phiopt.cc (factor_out_conditional_operation): Ignore nops, labels and predicts for heuristic for conversion with a constant. gcc/testsuite/ChangeLog: * c-c++-common/torture/pr116098-1.c: New test. * gcc.target/aarch64/csel-1.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-08-31testsuite: Change what is being tested for pr66726-2.cAndrew Pinski1-1/+1
r14-575-g6d6c17e45f62cf changed the debug dump message but the testcase pr66726-2.c was not updated for the change. The testcase was searching to make sure we didn't factor out a conversion but the testcase was no longer testing that so we needed to update what was being searched for. Tested on x86_64-linux. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr66726-2.c: Update scan dump message. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-08-31Fortran: downgrade use associated namelist group name to legacy extensionHarald Anlauf2-3/+4
The Fortran standard disallows use associated names as namelist group name (e.g. F2003:C581, but also later standards). This feature is a gfortran legacy extension, and we should give a warning even for -std=gnu. gcc/fortran/ChangeLog: * match.cc (gfc_match_namelist): Downgrade feature from GNU to legacy extension. gcc/testsuite/ChangeLog: * gfortran.dg/pr88169_3.f90: Adjust pattern.
2024-08-31c++: Add unsequenced C++ testcaseJakub Jelinek1-0/+53
This is the testcase I wrote originally and which on top of the https://gcc.gnu.org/pipermail/gcc-patches/2024-August/659154.html patch didn't behave the way I wanted (no warning and no optimizations of [[unsequenced]] function templates which don't have pointer/reference arguments. Posting this separately, because it depends on the above mentioned patch as well as the PR116175 https://gcc.gnu.org/pipermail/gcc-patches/2024-August/659157.html patch. 2024-08-31 Jakub Jelinek <jakub@redhat.com> * g++.dg/ext/attr-unsequenced-1.C: New test.
2024-08-31c: Add support for unsequenced and reproducible attributesJakub Jelinek25-9/+979
C23 added in N2956 ( https://open-std.org/JTC1/SC22/WG14/www/docs/n2956.htm ) two new attributes, which are described as similar to GCC const and pure attributes, but they aren't really same and it seems that even the paper is missing some of the differences. The paper says unsequenced is the same as const on functions without pointer arguments and reproducible is the same as pure on such functions (except that they are function type attributes rather than function declaration ones), but it seems the paper doesn't consider the finiteness GCC relies on (aka non-DECL_LOOPING_CONST_OR_PURE_P) - the paper only talks about using the attributes for CSE etc., not for DCE. The following patch introduces (for now limited) support for those attributes, both as standard C23 attributes and as GNU extensions (the difference is that the patch is then less strict on where it allows them, like other function type attributes they can be specified on function declarations as well and apply to the type, while C23 standard ones must go on the function declarators (i.e. after closing paren after function parameters) or in type specifiers of function type. If function doesn't have any pointer/reference arguments, the patch adds additional internal attribute with " noptr" suffix which then is used by flags_from_decl_or_type to handle those easy cases as ECF_CONST|ECF_LOOPING_CONST_OR_PURE or ECF_PURE|ECF_LOOPING_CONST_OR_PURE The harder cases aren't handled right now, I'd hope they can be handled incrementally. I wonder whether we shouldn't emit a warning for the gcc.dg/c23-attr-{reproducible,unsequenced}-5.c cases, while the standard clearly specifies that composite types should union the attributes and it is what GCC implements for decades, for ?: that feels dangerous for the new attributes, it would be much better to be conservative on say (cond ? unsequenced_function : normal_function) (args) There is no diagnostics on incorrect [[unsequenced]] or [[reproducible]] function definitions, while I think diagnosing non-const static/TLS declarations in the former could be easy, the rest feels hard. E.g. the const/pure discovery can just punt on everything it doesn't understand, but complete diagnostics would need to understand it. 2024-08-31 Jakub Jelinek <jakub@redhat.com> PR c/116130 gcc/ * doc/extend.texi (unsequenced, reproducible): Document new function type attributes. * calls.cc (flags_from_decl_or_type): Handle "unsequenced noptr" and "reproducible noptr" attributes. gcc/c-family/ * c-attribs.cc (c_common_gnu_attributes): Add entries for "unsequenced", "reproducible", "unsequenced noptr" and "reproducible noptr" attributes. (handle_unsequenced_attribute): New function. (handle_reproducible_attribute): Likewise. * c-common.h (handle_unsequenced_attribute): Declare. (handle_reproducible_attribute): Likewise. * c-lex.cc (c_common_has_attribute): Return 202311 for standard unsequenced and reproducible attributes. gcc/c/ * c-decl.cc (handle_std_unsequenced_attribute): New function. (handle_std_reproducible_attribute): Likewise. (std_attributes): Add entries for "unsequenced" and "reproducible" attributes. (c_warn_type_attributes): Add TYPE argument. Allow unsequenced or reproducible attributes if it is FUNCTION_TYPE. (groktypename): Adjust c_warn_type_attributes caller. (grokdeclarator): Likewise. (finish_declspecs): Likewise. * c-parser.cc (c_parser_declaration_or_fndef): Likewise. * c-tree.h (c_warn_type_attributes): Add TYPE argument. gcc/testsuite/ * c-c++-common/attr-reproducible-1.c: New test. * c-c++-common/attr-reproducible-2.c: New test. * c-c++-common/attr-unsequenced-1.c: New test. * c-c++-common/attr-unsequenced-2.c: New test. * gcc.dg/c23-attr-reproducible-1.c: New test. * gcc.dg/c23-attr-reproducible-2.c: New test. * gcc.dg/c23-attr-reproducible-3.c: New test. * gcc.dg/c23-attr-reproducible-4.c: New test. * gcc.dg/c23-attr-reproducible-5.c: New test. * gcc.dg/c23-attr-reproducible-5-aux.c: New file. * gcc.dg/c23-attr-unsequenced-1.c: New test. * gcc.dg/c23-attr-unsequenced-2.c: New test. * gcc.dg/c23-attr-unsequenced-3.c: New test. * gcc.dg/c23-attr-unsequenced-4.c: New test. * gcc.dg/c23-attr-unsequenced-5.c: New test. * gcc.dg/c23-attr-unsequenced-5-aux.c: New file. * gcc.dg/c23-has-c-attribute-2.c: Add tests for unsequenced and reproducible attributes.
2024-08-31AVR: Don't print a space after , when printing instructions.Georg-Johann Lay1-12/+12
gcc/ * config/avr/avr.cc: Follow the convention to not add a space after comma when printing instructions.
2024-08-31Optimize initialization of small padded objectsAlexandre Oliva6-9/+132
When small objects containing padding bits (or bytes) are fully initialized, we will often store them in registers, and setting bitfields and other small fields will attempt to preserve the uninitialized padding bits, which tends to be expensive. Zero-initializing registers, OTOH, tends to be cheap. So, if we're optimizing, zero-initialize such small padded objects even if that's not needed for correctness. We can't zero-initialize all such padding objects, though: if there's no padding whatsoever, and all fields are initialized with nonzero, the zero initialization would be flagged as dead. That's why we introduce machinery to detect whether objects have padding bits. I considered distinguishing between bitfields, units and larger padding elements, but I didn't pursue that distinction. Since the object's zero-initialization subsumes fields' zero-initialization, the empty string test in builtin-snprintf-6.c's test_assign_aggregate would regress without the addition of native_encode_constructor. for gcc/ChangeLog * expr.cc (categorize_ctor_elements_1): Change p_complete to int, to distinguish complete initialization in presence or absence of uninitialized padding bits. (categorize_ctor_elements): Likewise. Adjust all callers... * expr.h (categorize_ctor_elements): ... and declaration. (type_has_padding_at_level_p): New. * gimple-fold.cc (type_has_padding_at_level_p): New. * fold-const.cc (native_encode_constructor): New. (native_encode_expr): Call it. * gimplify.cc (gimplify_init_constructor): Clear small non-addressable non-volatile objects with padding or other uninitialized fields as an optimization. for gcc/testsuite/ChangeLog * gcc.dg/init-pad-1.c: New.
2024-08-31Daily bump.GCC Administrator6-1/+115
2024-08-30c++: add fixed test [PR101099]Marek Polacek1-0/+6
-fconcepts-ts is no longer supported so this can't be made to ICE anymore. PR c++/101099 gcc/testsuite/ChangeLog: * g++.dg/concepts/pr101099.C: New test.
2024-08-30c++: add fixed test [PR115616]Marek Polacek1-0/+24
This got fixed by r15-2120. PR c++/115616 gcc/testsuite/ChangeLog: * g++.dg/template/friend83.C: New test.
2024-08-30c++: fix used but not defined warning for friendJason Merrill2-1/+14
Here limit_bad_template_recursion avoids instantiating foo, and then we wrongly warn that it isn't defined, because as a non-template (but templated) friend DECL_TEMPLATE_INSTANTIATION is false. gcc/cp/ChangeLog: * decl2.cc (c_parse_final_cleanups): Also check DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/used-inline1.C: New test.
2024-08-30Fortran: default-initialization of derived-type function results [PR98454]Harald Anlauf4-2/+163
gcc/fortran/ChangeLog: PR fortran/98454 * resolve.cc (resolve_symbol): Add default-initialization of non-allocatable, non-pointer derived-type function results. gcc/testsuite/ChangeLog: PR fortran/98454 * gfortran.dg/alloc_comp_class_4.f03: Remove bogus pattern. * gfortran.dg/pdt_26.f03: Adjust expected count. * gfortran.dg/derived_result_3.f90: New test.
2024-08-30gdbhooks: Fix printing of vec with vl_ptr layoutAlex Coplan1-3/+27
As it stands, the pretty printing of GCC's vecs by gdbhooks.py only handles vectors with vl_embed layout. As such, when encountering a vec with vl_ptr layout, GDB would print a diagnostic like: gdb.error: There is no member or method named m_vecpfx. when (e.g.) any such vec occurred in a backtrace. This patch extends VecPrinter.children to also handle vl_ptr vectors. gcc/ChangeLog: * gdbhooks.py (VEC_KIND_EMBED): New. (VEC_KIND_PTR): New. (get_vec_kind): New. (VecPrinter.children): Also handle vectors with vl_ptr layout.
2024-08-30Don't remove /usr/lib and /lib from when passing to the linker [PR97304/104707]Andrew Pinski1-18/+6
With newer ld, the default search library path does not include /usr/lib nor /lib but the driver decides to not pass -L down to the link for these and then in some/most cases libc is not found. This code dates from at least 1992 and it is done in a way which is not safe and does not make sense. So let's remove it. Bootstrapped and tested on x86_64-linux-gnu (which defaults to being a multilib). gcc/ChangeLog: PR driver/104707 PR driver/97304 * gcc.cc (is_directory): Don't not include /usr/lib and /lib for library directory pathes. Remove library argument. (add_to_obstack): Update call to is_directory. (driver_handle_option): Likewise. (spec_path): Likewise. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-08-30middle-end: Remove integer_three_node [PR116537]Andrew Pinski4-4/+1
After the small expansion patch for __builtin_prefetch, the only use of integer_three_node is inside tree-ssa-loop-prefetch.cc so let's remove it as the loop prefetch pass is not enabled these days by default and having a tree node around just for that pass is a little wasteful. Integer constants are also shared these days so calling build_int_cst will use the cached node anyways. Bootstrapped and tested on x86_64-linux. PR middle-end/116537 gcc/ChangeLog: * tree-core.h (enum tree_index): Remove TI_INTEGER_THREE * tree-ssa-loop-prefetch.cc (issue_prefetch_ref): Call build_int_cst instead of using integer_three_node. * tree.cc (build_common_tree_nodes): Remove initialization of integer_three_node. * tree.h (integer_three_node): Delete. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-08-30expand: Small speed up expansion of __builtin_prefetchAndrew Pinski1-14/+14
This is a small speed up of the expansion of __builtin_prefetch. Basically for the optional arguments, no reason to call expand_normal on a constant integer that we know the value, just replace it with GEN_INT/const0_rtx instead. Bootstrapped and tested on x86_64-linux. gcc/ChangeLog: * builtins.cc (expand_builtin_prefetch): Rewrite expansion of the optional arguments to not expand known constants.
2024-08-30PR modula2/116181: m2rts fix -Wodr warningGaius Mulley2-31/+7
This patch fixes the -Wodr warning seen in pge-boot/m2rts.h when building pge. gcc/m2/ChangeLog: PR modula2/116181 * pge-boot/GM2RTS.h: Regenerate. * pge-boot/m2rts.h: Ditto. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2024-08-30Avoid division by zero via constant_multiple_pRichard Biener1-2/+4
With recent SLP vectorization patches I see RISC-V divison by zero for gfortran.dg/matmul_10.f90 and others in get_group_load_store_type which does && can_div_trunc_p (group_size * LOOP_VINFO_VECT_FACTOR (loop_vinfo) - gap, nunits, &tem, &remain) && (known_eq (remain, 0u) || (constant_multiple_p (nunits, remain, &num) && (vector_vector_composition_type (vectype, num, &half_vtype) != NULL_TREE)))) overrun_p = false; where for [2, 2] / [0, 2] the condition doesn't reflect what we are trying to test - that, when remain is zero or, when non-zero, nunits is a multiple of remain, we can avoid touching a gap via loading smaller pieces and vector composition. It isn't safe to change the known_eq to maybe_eq so instead require known_ne (remain, 0u) before doing constant_multiple_p. There's the corresponding code in vectorizable_load that's known to have a latent similar issue, so sync that up as well. * tree-vect-stmts.cc (get_group_load_store_type): Check known_ne (remain, 0u) before doing constant_multiple_p. (vectorizable_load): Likewise.
2024-08-30Do not bother with reassociation in SLP discovery for single-laneRichard Biener1-0/+2
It just clutters the dump files and takes up compile-time. * tree-vect-slp.cc (vect_build_slp_tree_2): Disable SLP reassociation for single-lane.
2024-08-30c++: Allow standard attributes after closing square bracket in new-type-id ↵Jakub Jelinek3-8/+41
[PR110345] For C++ 26 P2552R3 I went through all the spots (except modules) where attribute-specifier-seq appears in the grammar and tried to construct a testcase in all those spots, for now for [[deprecated]] attribute. The first thing I found is that we aren't parsing standard attributes in noptr-new-declarator - https://eel.is/c++draft/expr.new#1 The following patch parses it there, for the non-outermost arrays applies normally the attributes to the array type, for the outermost where we just set *nelts and don't really build an array type just warns that we ignore those attributes (or, do you think we should just build an array type in that case and just take its element type?). 2024-08-30 Jakub Jelinek <jakub@redhat.com> PR c++/110345 * parser.cc (make_array_declarator): Add STD_ATTRS argument, set declarator->std_attributes to it. (cp_parser_new_type_id): Warn on non-ignored std_attributes on the array declarator which is being omitted. (cp_parser_direct_new_declarator): Parse standard attributes after closing square bracket, pass it to make_array_declarator. (cp_parser_direct_declarator): Pass std_attrs to make_array_declarator instead of setting declarator->std_attributes manually. * g++.dg/cpp0x/gen-attrs-80.C: New test. * g++.dg/cpp0x/gen-attrs-81.C: New test.
2024-08-30Check avx upper register for parallel.liuhongt2-13/+49
For function arguments/return, when it's BLK mode, it's put in a parallel with an expr_list, and the expr_list contains the real mode and registers. Current ix86_check_avx_upper_register only checked for SSE_REG_P, and failed to handle that. The patch extend the handle to each subrtx. gcc/ChangeLog: PR target/116512 * config/i386/i386.cc (ix86_check_avx_upper_register): Iterate subrtx to scan for avx upper register. (ix86_check_avx_upper_stores): Inline old ix86_check_avx_upper_register. (ix86_avx_u128_mode_needed): Ditto, and replace FOR_EACH_SUBRTX with call to new ix86_check_avx_upper_register. gcc/testsuite/ChangeLog: * gcc.target/i386/pr116512.c: New test.
2024-08-30Daily bump.GCC Administrator7-1/+748
2024-08-29SARIF output: implement embedded URLs in messages (§3.11.6; PR other/116419)David Malcolm7-96/+636
GCC diagnostic messages can contain URLs, such as to our documentation when we suggest an option name to correct a misspelling. SARIF message strings can contain embedded URLs in the plain text messages (see SARIF v2.1.0 §3.11.6), but previously we were simply dropping any URLs from the diagnostic messages. This patch adds support for encoding URLs into messages in our SARIF output, using the pp_token machinery added in the previous patch. As well as supporting URLs, the patch also adjusts how we report event IDs in SARIF message, so that rather than e.g. "text": "second 'free' here; first 'free' was at (1)" we now report: "text": "second 'free' here; first 'free' was at [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)" i.e. the text "(1)" now has a embedded link referring within the sarif log to the threadFlowLocation object for the other event, via JSON pointer (see §3.10.3 "URIs that use the sarif scheme"). Doing so requires the arious objects to know their index within their containing array, requiring some reworking of how they are constructed. gcc/ChangeLog: PR other/116419 * diagnostic-event-id.h (diagnostic_event_id_t::zero_based): New. * diagnostic-format-sarif.cc: Include "pretty-print-format-impl.h" and "pretty-print-urlifier.h". (sarif_result::sarif_result): Add param "idx_within_parent". (sarif_result::get_index_within_parent): New accessor. (sarif_result::m_idx_within_parent): New field. (sarif_code_flow::sarif_code_flow): New ctor. (sarif_code_flow::get_parent): New accessor. (sarif_code_flow::get_index_within_parent): New accessor. (sarif_code_flow::m_parent): New field. (sarif_code_flow::m_thread_id_map): New field. (sarif_code_flow::m_thread_flows_arr): New field. (sarif_code_flow::m_all_tfl_objs): New field. (sarif_thread_flow::sarif_thread_flow): Add "parent" and "idx_within_parent" params. (sarif_thread_flow::get_parent): New accessor. (sarif_thread_flow::get_index_within_parent): New accessor. (sarif_thread_flow::m_parent): New field. (sarif_thread_flow::m_idx_within_parent): New field. (sarif_thread_flow_location::sarif_thread_flow_location): New ctor. (sarif_thread_flow_location::get_parent): New accessor. (sarif_thread_flow_location::get_index_within_parent): New accessor. (sarif_thread_flow_location::m_parent): New field. (sarif_thread_flow_location::m_idx_within_parent): New field. (sarif_builder::get_code_flow_for_event_ids): New accessor. (class sarif_builder::sarif_token_printer): New. (sarif_builder::m_token_printer): New member. (sarif_builder::m_next_result_idx): New field. (sarif_builder::m_current_code_flow): New field. (sarif_code_flow::get_or_append_thread_flow): New. (sarif_code_flow::get_thread_flow): New. (sarif_code_flow::add_location): New. (sarif_code_flow::get_thread_flow_loc_obj): New. (sarif_thread_flow::add_location): Create the new sarif_thread_flow_location internally, rather than passing it in as a parm so that we can keep track of its index in the array. Return a reference to it. (sarif_builder::sarif_builder): Initialize m_token_printer, m_next_result_idx, and m_current_code_flow. (sarif_builder::on_report_diagnostic): Pass index to make_result_object. (sarif_builder::make_result_object): Add "idx_within_parent" param and pass to sarif_result ctor. Pass code flow index to call to make_code_flow_object. (make_sarif_url_for_event): New. (sarif_builder::make_code_flow_object): Add "idx_within_parent" param and pass it to sarif_code_flow ctor. Reimplement walking of events so that we first create threadFlow objects for each thread, then populate them with threadFlowLocation objects, so that the IDs work. Set m_current_code_flow whilst creating the latter, so that we can create correct URIs for "%@". (sarif_builder::make_thread_flow_location_object): Replace with... (sarif_builder::populate_thread_flow_location_object): ...this. (sarif_output_format::get_builder): New accessor. (sarif_begin_embedded_link): New. (sarif_end_embedded_link): New. (sarif_builder::sarif_token_printer::print_tokens): New. (diagnostic_output_format_init_sarif): Add "fmt" param; use it to set the token printer and output format for the context. (diagnostic_output_format_init_sarif_stderr): Move responsibility for setting the context's output format to within diagnostic_output_format_init_sarif. (diagnostic_output_format_init_sarif_file): Likewise. (diagnostic_output_format_init_sarif_stream): Likewise. (test_sarif_diagnostic_context::test_sarif_diagnostic_context): Likewise. (selftest::test_make_location_object): Provide an idx for the result. (selftest::get_result_from_log): New. (selftest::get_message_from_log): New. (selftest::test_message_with_embedded_link): New test. (selftest::diagnostic_format_sarif_cc_tests): Call it. * pretty-print-format-impl.h: Include "diagnostic-event-id.h". (pp_token::kind): Add "event_id". (struct pp_token_event_id): New. (is_a_helper <pp_token_event_id *>::test): New. (is_a_helper <const pp_token_event_id *>::test): New. * pretty-print.cc (pp_token::dump): Handle kind::event_id. (pretty_printer::format): Update handling of "%@" in phase 2 so that we add a pp_token_event_id, rather that the text "(N)". (default_token_printer): Handle pp_token::kind::event_id by printing the text "(N)". gcc/testsuite/ChangeLog: PR other/116419 * gcc.dg/sarif-output/bad-pragma.c: New test. * gcc.dg/sarif-output/test-bad-pragma.py: New test. * gcc.dg/sarif-output/test-include-chain-2.py (test_location_relationships): Update expected text of event to include an intra-sarif URI to the other event. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-08-29pretty-print: reimplement pp_format with a new struct pp_tokenDavid Malcolm14-535/+1483
The following patch rewrites the internals of pp_format. A pretty_printer's output_buffer maintains a stack of chunk_info instances, each one responsible for handling a call to pp_format, where having a stack allows us to support re-entrant calls to pp_format on the same pretty_printer. Previously a chunk_info merely stored buffers of accumulated text per unformatted run and per formatted argument. This led to various special-casing for handling: - urlifiers, needing class quoting_info to handle awkard cases where the run of quoted text could be split between stages 1 and 2 of formatting - dumpfiles, where the optinfo machinery could lead to objects being stashed during formatting for later replay to JSON optimization records - in the C++ frontend, the format codes %H and %I can't be processed until we've seen both, leading to awkward code to manipulate the text buffers Further, supporting URLs in messages in SARIF output (PR other/116419) would add additional manipulations of text buffers, since our internal pp_begin_url API gives the URL at the beginning of the wrapped text, whereas SARIF's format for embedded URLs has the URL *after* the wrapped text. Also when handling "%@" we wouldn't necessarily know the URL of an event ID until later, requiring further nasty special-case manipulation of text buffers. This patch rewrites pretty-print formatting by introducing a new intermediate representation during formatting: pp_token and pp_token_list. Rather than simply accumulating a buffer of "char" in the chunk_obstack during formatting, we now also accumulate a pp_token_list, a doubly-linked list of pp_token, which can be: - text buffers - begin/end colorization - begin/end quote - begin/end URL - "custom data" tokens Working at the level of tokens rather than just text buffers allows the various awkward special cases above to be replaced with uniform logic. For example, all "urlification" is now done in phase 3 of formatting, in one place, by looking for [..., BEGIN_QUOTE, TEXT, END_QUOTE, ...] and injecting BEGIN_URL and END_URL wrapper tokens when the urlifier has a URL for TEXT. Doing so greatly simplifies the urlifier code, allowing the removal of class quoting_info. The tokens and token lists are allocated on the chunk_obstack, and so there's no additional heap activity required, with the memory reclaimed when the chunk_obstack is freed after phase 3 of formatting. New kinds of pp_token can be added as needed to support output formats. For example, the followup patch adds a token for "%@" for events IDs, to better support SARIF output. No functional change intended. gcc/c/ChangeLog: * c-objc-common.cc (c_tree_printer): Convert final param from const char ** to pp_token_list &. gcc/cp/ChangeLog: * error.cc: Include "make-unique.h". (deferred_printed_type::m_buffer_ptr): Replace with... (deferred_printed_type::m_printed_text): ...this and... (deferred_printed_type::m_token_list): ...this. (deferred_printed_type::deferred_printed_type): Update ctors for above changes. (deferred_printed_type::set_text_for_token_list): New. (append_formatted_chunk): Pass chunk_obstack to append_formatted_chunk. (add_quotes): Delete. (cxx_format_postprocessor::handle): Reimplement to call deferred_printed_type::set_text_for_token_list, rather than store buffer pointers. (defer_phase_2_of_type_diff): Replace param "buffer_ptr" with "formatted_token_list". Reimplement by storing a pointer to formatted_token_list so that the postprocessor can put its text there. (cp_printer): Convert param "buffer_ptr" to "formatted_token_list". Update calls to defer_phase_2_of_type_diff accordingly. gcc/ChangeLog: * diagnostic.cc (diagnostic_context::report_diagnostic): Don't pass m_urlifier to pp_format, as urlification now happens in phase 3. * dump-context.h (class dump_pretty_printer): Update leading comment. (dump_pretty_printer::emit_items): Drop decl. (dump_pretty_printer::set_optinfo): New. (class dump_pretty_printer::stashed_item): Delete class. (class dump_pretty_printer::custom_token_printer): New class. (dump_pretty_printer::format_decoder_cb): Convert param from const char ** to pp_token_list &. (dump_pretty_printer::decode_format): Likewise. (dump_pretty_printer::stash_item): Likewise. (dump_pretty_printer::emit_any_pending_textual_chunks): Drop decl. (dump_pretty_printer::m_stashed_items): Delete field. (dump_pretty_printer::m_token_printer): New member data. * dumpfile.cc (struct wrapped_optinfo_item): New. (dump_pretty_printer::dump_pretty_printer): Update for dropping of field m_stashed_items and new field m_token_printer. (dump_pretty_printer::emit_items): Delete; we now use pp_output_formatted_text.. (dump_pretty_printer::emit_any_pending_textual_chunks): Delete. (dump_pretty_printer::stash_item): Convert param from const char ** to pp_token_list &. (dump_pretty_printer::format_decoder_cb): Likewise. (dump_pretty_printer::decode_format): Likewise. (dump_pretty_printer::custom_token_printer::print_tokens): New. (dump_pretty_printer::custom_token_printer::emit_any_pending_textual_chunks): New. (dump_context::dump_printf_va): Call set_optinfo on the dump_pretty_printer. Replace call to emit_items with a call to pp_output_formatted_text. * opt-problem.cc (opt_problem::opt_problem): Replace call to emit_items with call to set_optinfo and call to pp_output_formatted_text. * pretty-print-format-impl.h (struct pp_token): New. (struct pp_token_text): New. (is_a_helper <pp_token_text *>::test): New. (is_a_helper <const pp_token_text *>::test): New. (struct pp_token_begin_color): New. (is_a_helper <pp_token_begin_color *>::test): New. (is_a_helper <const pp_token_begin_color *>::test): New. (struct pp_token_end_color): New. (struct pp_token_begin_quote): New. (struct pp_token_end_quote): New. (struct pp_token_begin_url): New. (is_a_helper <pp_token_begin_url*>::test): New. (is_a_helper <const pp_token_begin_url*>::test): New. (struct pp_token_end_url): New. (struct pp_token_custom_data): New. (is_a_helper <pp_token_custom_data *>::test): New. (is_a_helper <const pp_token_custom_data *>::test): New. (class pp_token_list): New. (chunk_info::get_args): Drop. (chunk_info::get_quoting_info): Drop. (chunk_info::get_token_lists): New accessor. (chunk_info::append_formatted_chunk): Add obstack & param. (chunk_info::dump): New decls. (chunk_info::m_args): Convert element type from const char * to pp_token_list *. Rewrite/update comment. (chunk_info::m_quotes): Drop field. * pretty-print-markup.h (class pp_token_list): New forward decl. (pp_markup::context::context): Drop urlifier param; add formatted_token_list param. (pp_markup::context::push_back_any_text): New decl. (pp_markup::context::m_urlifier): Drop field. (pp_markup::context::m_formatted_token_list): New field. * pretty-print-urlifier.h: Update comment. * pretty-print.cc: Define INCLUDE_MEMORY. Include "make-unique.h". (default_token_printer): New forward decl. (obstack_append_string): Delete. (urlify_quoted_string): Delete. (pp_token::pp_token): New. (pp_token::dump): New. (allocate_object): New. (class quoting_info): Delete. (pp_token::operator new): New. (pp_token::operator delete): New. (pp_token_list::operator new): New. (pp_token_list::operator delete): New. (pp_token_list::pp_token_list): New. (pp_token_list::~pp_token_list): New. (pp_token_list::push_back_text): New. (pp_token_list::push_back): New. (pp_token_list::push_back_list): New. (pp_token_list::pop_front): New. (pp_token_list::remove_token): New. (pp_token_list::insert_after): New. (pp_token_list::replace_custom_tokens): New. (pp_token_list::merge_consecutive_text_tokens): New. (pp_token_list::apply_urlifier): New. (pp_token_list::dump): New. (chunk_info::append_formatted_chunk): Add obstack & param and use it to reimplement in terms of token lists. (chunk_info::pop_from_output_buffer): Drop m_quotes. (chunk_info::on_begin_quote): Delete. (chunk_info::dump): New. (chunk_info::on_end_quote): Delete. (push_back_any_text): New. (pretty_printer::format): Drop "urlifier" param and quoting_info logic. Convert "formatters" and "args" from const ** to pp_token_list **. Reimplement so that rather than just accumulating a text buffer in the chunk_obstack for each arg, instead also accumulate a pp_token_list and pp_tokens for each arg. (auto_obstack::operator obstack &): New. (quoting_info::handle_phase_3): Delete. (pp_output_formatted_text): Reimplement in terms of manipulations of pp_token_lists, rather than char buffers. Call default_token_printer, or m_token_printer's print_tokens vfunc. (default_token_printer): New. (pretty_printer::pretty_printer): Initialize m_token_printer in both ctors. (pp_markup::context::begin_quote): Reimplement to use token list. (pp_markup::context::end_quote): Likewise. (pp_markup::context::begin_highlight_color): Likewise. (pp_markup::context::end_highlight_color): Likewise. (pp_markup::context::push_back_any_text): New. (selftest::test_merge_consecutive_text_tokens): New. (selftest::test_custom_tokens_1): New. (selftest::test_custom_tokens_2): New. (selftest::pp_printf_with_urlifier): Drop "urlifier" param from call to pp_format. (selftest::test_urlification): Add test of the example from pretty-print-format-impl.h. (selftest::pretty_print_cc_tests): Call the new selftest functions. * pretty-print.h (class quoting_info): Drop forward decl. (class pp_token_list): New forward decl. (printer_fn): Convert final param from const char ** to pp_token_list &. (class token_printer): New. (class pretty_printer): Add pp_output_formatted_text as friend. (pretty_printer::set_token_printer): New. (pretty_printer::format): Drop urlifier param as this now happens in phase 3. (pretty_printer::m_format_decoder): Update comment. (pretty_printer::m_token_printer): New field. (pp_format): Drop urlifier param. * tree-diagnostic.cc (default_tree_printer): Convert final param from const char ** to pp_token_list &. * tree-diagnostic.h: Likewise for decl. gcc/fortran/ChangeLog: * error.cc (gfc_format_decoder): Convert final param from const char **buffer_ptr to pp_token_list &formatted_token_list, and update call to default_tree_printer accordingly. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-08-29pretty-print: move class chunk_info into its own headerDavid Malcolm5-44/+74
No functional change intended. gcc/cp/ChangeLog: * error.cc: Include "pretty-print-format-impl.h". gcc/ChangeLog: * dumpfile.cc: Include "pretty-print-format-impl.h". * pretty-print-format-impl.h: New file, based on material from pretty-print.h. * pretty-print.cc: Include "pretty-print-format-impl.h". * pretty-print.h (chunk_info): Replace full declaration with a forward decl, moving full decl to pretty-print-format-impl.h. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-08-29Use std::unique_ptr for optinfo_itemDavid Malcolm47-88/+137
As preliminary work towards an overhaul of how optinfo_items interact with dump_pretty_printer, replace uses of optinfo_item * with std::unique_ptr<optinfo_item> to make ownership clearer. No functional change intended. gcc/ChangeLog: * config/aarch64/aarch64.cc: Define INCLUDE_MEMORY. * config/arm/arm.cc: Likewise. * config/i386/i386.cc: Likewise. * config/loongarch/loongarch.cc: Likewise. * config/riscv/riscv-vector-costs.cc: Likewise. * config/riscv/riscv.cc: Likewise. * config/rs6000/rs6000.cc: Likewise. * dump-context.h (dump_context::emit_item): Convert "item" param from * to const &. (dump_pretty_printer::stash_item): Convert "item" param from optinfo_ * to std::unique_ptr<optinfo_item>. (dump_pretty_printer::emit_item): Likewise. * dumpfile.cc: Include "make-unique.h". (make_item_for_dump_gimple_stmt): Replace uses of optinfo_item * with std::unique_ptr<optinfo_item>. (dump_context::dump_gimple_stmt): Likewise. (make_item_for_dump_gimple_expr): Likewise. (dump_context::dump_gimple_expr): Likewise. (make_item_for_dump_generic_expr): Likewise. (dump_context::dump_generic_expr): Likewise. (make_item_for_dump_symtab_node): Likewise. (dump_pretty_printer::emit_items): Likewise. (dump_pretty_printer::emit_any_pending_textual_chunks): Likewise. (dump_pretty_printer::emit_item): Likewise. (dump_pretty_printer::stash_item): Likewise. (dump_pretty_printer::decode_format): Likewise. (dump_context::dump_printf_va): Fix overlong line. (make_item_for_dump_dec): Replace uses of optinfo_item * with std::unique_ptr<optinfo_item>. (dump_context::dump_dec): Likewise. (dump_context::dump_symtab_node): Likewise. (dump_context::begin_scope): Likewise. (dump_context::emit_item): Likewise. * gimple-loop-interchange.cc: Define INCLUDE_MEMORY. * gimple-loop-jam.cc: Likewise. * gimple-loop-versioning.cc: Likewise. * graphite-dependences.cc: Likewise. * graphite-isl-ast-to-gimple.cc: Likewise. * graphite-optimize-isl.cc: Likewise. * graphite-poly.cc: Likewise. * graphite-scop-detection.cc: Likewise. * graphite-sese-to-poly.cc: Likewise. * graphite.cc: Likewise. * opt-problem.cc: Likewise. * optinfo.cc (optinfo::add_item): Convert "item" param from optinfo_ * to std::unique_ptr<optinfo_item>. (optinfo::emit_for_opt_problem): Update for change to dump_context::emit_item. * optinfo.h: Add #error to fail immediately if INCLUDE_MEMORY wasn't defined, rather than fail to find std::unique_ptr. (optinfo::add_item): Convert "item" param from optinfo_ * to std::unique_ptr<optinfo_item>. * sese.cc: Define INCLUDE_MEMORY. * targhooks.cc: Likewise. * tree-data-ref.cc: Likewise. * tree-if-conv.cc: Likewise. * tree-loop-distribution.cc: Likewise. * tree-parloops.cc: Likewise. * tree-predcom.cc: Likewise. * tree-ssa-live.cc: Likewise. * tree-ssa-loop-ivcanon.cc: Likewise. * tree-ssa-loop-ivopts.cc: Likewise. * tree-ssa-loop-prefetch.cc: Likewise. * tree-ssa-loop-unswitch.cc: Likewise. * tree-ssa-phiopt.cc: Likewise. * tree-ssa-threadbackward.cc: Likewise. * tree-ssa-threadupdate.cc: Likewise. * tree-vect-data-refs.cc: Likewise. * tree-vect-generic.cc: Likewise. * tree-vect-loop-manip.cc: Likewise. * tree-vect-loop.cc: Likewise. * tree-vect-patterns.cc: Likewise. * tree-vect-slp-patterns.cc: Likewise. * tree-vect-slp.cc: Likewise. * tree-vect-stmts.cc: Likewise. * tree-vectorizer.cc: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/dump_plugin.c: Define INCLUDE_MEMORY. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-08-29Fortran: fix ICE with use with rename of namelist member [PR116530]Harald Anlauf2-1/+29
gcc/fortran/ChangeLog: PR fortran/116530 * trans-io.cc (transfer_namelist_element): Prevent NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/116530 * gfortran.dg/use_rename_12.f90: New test.
2024-08-29hppa: Fix handling of unscaled index addresses on HP-UXJohn David Anglin1-12/+8
The PA-RISC architecture uses the top two bits of memory pointers to select space registers. The space register ID is ored with the pointer offset to compute the global virtual address for an access. The new late combine passes broke gcc on HP-UX. One of these passes runs after reload. The existing code assumed no unscaled index instructions would be created after reload as the REG_POINTER flag is not reliable after reload. The new pass sometimes interchanged the base and index registers, causing these instructions to fault when the wrong space register was selected. I investigated various alternatives to try to retain generation of unscaled index instructions on HP-UX. It's not possible to simply treat unscaled index addresses as not legitimate after reload as sometimes instructions need to be rerecognized after reload. So, we needed to allow unscaled index addresses after reload and to disable the late combine passes. I had noticed that reversing the current order of base and index register canonicalization resulted in more accesses using unscaled index addresses. However, this exposed issues with the REG_POINTER flag. The flag is not propagated when a constant is added to a pointer. Tree opimization sometimes adds two pointers. I found that I had to treat the result as a pointer but the addition generally corrupts the space register bits. These get fixed when a negative pointer is added. Finally, the REG_POINTER flag isn't set when a pointer is passed in a function call. I couldn't get this approach to work. Thus, I came to the conclusion that the best approach was to disable use of unscaled index addresses on HP-UX. I don't think this impacts performance significantly. Code size might get slightly larger but we get some or more back from having the late combine passes. 2024-08-29 John David Anglin <danglin@gcc.gnu.org> gcc/ChangeLog: * config/pa/pa.cc (load_reg): Don't generate load with unscaled index address when !TARGET_NO_SPACE_REGS. (pa_legitimate_address_p): Only allow unscaled index addresses when TARGET_NO_SPACE_REGS.
2024-08-29expand: Allow widdening optab when expanding popcount==1 [PR116508]Andrew Pinski2-2/+47
After adding popcount{qi,hi}2 to the aarch64 backend, I noticed that the expansion for popcount==1 was no longer trying to do the trick of handling popcount==1 as `(arg ^ (arg - 1)) > arg - 1`. The problem is the expansion was using OPTAB_DIRECT, when using OPTAB_WIDEN will allow modes which are smaller than SImode (in the aarch64 case). Note QImode's cost still needs some improvements so part of popcnt-eq-1.c is xfailed. Though there is a check to make sure the costs are compared now. Built and tested on aarch64-linux-gnu. PR middle-end/116508 gcc/ChangeLog: * internal-fn.cc (expand_POPCOUNT): Use OPTAB_WIDEN for PLUS and XOR/AND expansion. gcc/testsuite/ChangeLog: * gcc.target/aarch64/popcnt-eq-1.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-08-29ada: Fix assertion failure on private limited with clauseEric Botcazou1-0/+1
This checks that the name is of an entity before accessing its Entity field. gcc/ada/ * sem_ch8.adb (Has_Private_With): Add test on Is_Entity_Name.