aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-08-08RISC-V: Support CALL conditional autovec patternsJuzhe-Zhong117-309/+3869
This patch is depending on middle-end patch on vectorizable_call. Consider this following case: void foo (float * __restrict a, float * __restrict b, int * __restrict cond, int n) { for (int i = 0; i < n; i++) if (cond[i]) a[i] = b[i] + a[i]; } Before this patch (**NO** -ffast-math): <source>:5:21: missed: couldn't vectorize loop <source>:5:21: missed: not vectorized: control flow in loop. After this patch: foo: ble a3,zero,.L5 mv a6,a0 .L3: vsetvli a5,a3,e8,mf4,ta,ma vle32.v v0,0(a2) vsetvli a7,zero,e32,m1,ta,ma slli a4,a5,2 vmsne.vi v0,v0,0 sub a3,a3,a5 vsetvli zero,a5,e32,m1,tu,mu ------> must be TUMU vle32.v v2,0(a0),v0.t vle32.v v1,0(a1),v0.t vfadd.vv v1,v1,v2,v0.t ------> generated by COND_LEN_ADD with real mask and len. vse32.v v1,0(a6),v0.t add a2,a2,a4 add a1,a1,a4 add a0,a0,a4 add a6,a6,a4 bne a3,zero,.L3 .L5: ret gcc/ChangeLog: * config/riscv/autovec.md (cond_<optab><mode>): New pattern. (cond_len_<optab><mode>): Ditto. (cond_fma<mode>): Ditto. (cond_len_fma<mode>): Ditto. (cond_fnma<mode>): Ditto. (cond_len_fnma<mode>): Ditto. (cond_fms<mode>): Ditto. (cond_len_fms<mode>): Ditto. (cond_fnms<mode>): Ditto. (cond_len_fnms<mode>): Ditto. * config/riscv/riscv-protos.h (riscv_get_v_regno_alignment): Export global. (enum insn_type): Add new enum type. (prepare_ternary_operands): New function. * config/riscv/riscv-v.cc (emit_vlmax_masked_fp_mu_insn): Ditto. (emit_nonvlmax_tumu_insn): Ditto. (emit_nonvlmax_fp_tumu_insn): Ditto. (expand_cond_len_binop): Add condtional operations. (expand_cond_len_ternop): Ditto. (prepare_ternary_operands): New function. * config/riscv/riscv.cc (riscv_memmodel_needs_amo_release): Export riscv_get_v_regno_alignment as global scope. * config/riscv/vector.md: Fix ternary bugs. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/rvv.exp: Add condition tests. * gcc.target/riscv/rvv/autovec/cond/cond_arith-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith-6.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith-7.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith-8.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith-9.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-6.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-7.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-8.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_arith_run-9.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fadd-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fadd-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fadd-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fadd-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fadd_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fadd_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fadd_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fadd_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-6.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-7.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-8.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-6.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-7.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma_run-8.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmax-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmax-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmax-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmax-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmax_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmax_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmax_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmax_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmin-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmin-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmin-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmin-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmin_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmin_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmin_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmin_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-6.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms_run-6.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmul-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmul-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmul-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmul-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmul_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmul_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmul_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_fmul_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_logical_run-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-6.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-7.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-8.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift-9.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-3.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-4.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-5.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-6.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-7.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-8.c: New test. * gcc.target/riscv/rvv/autovec/cond/cond_shift_run-9.c: New test. * gcc.target/riscv/rvv/autovec/reduc/reduc_call-1.c: New test. * gcc.target/riscv/rvv/autovec/reduc/reduc_call-2.c: New test. * gcc.target/riscv/rvv/autovec/reduc/reduc_call-3.c: New test. * gcc.target/riscv/rvv/autovec/reduc/reduc_call-4.c: New test. * gcc.target/riscv/rvv/autovec/reduc/reduc_call-5.c: New test.
2023-08-08tree-optimization/49955 - BB reduction with odd number of lanesRichard Biener3-1/+72
The following enhances BB reduction vectorization to support vectorizing only a subset of the lanes, keeping the rest as scalar ops. For now we try to make the number of lanes even by leaving alone the "last" lane. That's because SLP discovery with all lanes will fail too soon to get us any hint on which lane to strip and likewise we don't know what vector modes the target supports so restricting ourselves to power-of-two or other cases isn't easy. This is enough to get at the vectorization opportunity for the testcase in the PR - albeit with the chosen lanes not optimal but at least vectorizable. PR tree-optimization/49955 * tree-vectorizer.h (_slp_instance::remain_stmts): New. (SLP_INSTANCE_REMAIN_STMTS): Likewise. * tree-vect-slp.cc (vect_free_slp_instance): Release SLP_INSTANCE_REMAIN_STMTS. (vect_build_slp_instance): Make the number of lanes of a BB reduction even. (vectorize_slp_instance_root_stmt): Handle unvectorized defs of a BB reduction. * gfortran.dg/vect/pr49955.f: New testcase.
2023-08-08VECT: Support CALL vectorization for COND_LEN_*Ju-Zhe Zhong3-5/+78
Hi, Richard and Richi. Base on the suggestions from Richard: https://gcc.gnu.org/pipermail/gcc-patches/2023-July/625396.html This patch choose (1) approach that Richard provided, meaning: RVV implements cond_* optabs as expanders. RVV therefore supports both IFN_COND_ADD and IFN_COND_LEN_ADD. No dummy length arguments are needed at the gimple level. Such approach can make codes much cleaner and reasonable. Consider this following case: void foo (float * __restrict a, float * __restrict b, int * __restrict cond, int n) { for (int i = 0; i < n; i++) if (cond[i]) a[i] = b[i] + a[i]; } Output of RISC-V (32-bits) gcc (trunk) (Compiler #3) <source>:5:21: missed: couldn't vectorize loop <source>:5:21: missed: not vectorized: control flow in loop. ARM SVE: ... mask__27.10_51 = vect__4.9_49 != { 0, ... }; ... vec_mask_and_55 = loop_mask_49 & mask__27.10_51; ... vect__9.17_62 = .COND_ADD (vec_mask_and_55, vect__6.13_56, vect__8.16_60, vect__6.13_56); For RVV, we want IR as follows: ... _68 = .SELECT_VL (ivtmp_66, POLY_INT_CST [4, 4]); ... mask__27.10_51 = vect__4.9_49 != { 0, ... }; ... vect__9.17_60 = .COND_LEN_ADD (mask__27.10_51, vect__6.13_55, vect__8.16_59, vect__6.13_55, _68, 0); ... Both len and mask of COND_LEN_ADD are real not dummy. This patch has been fully tested in RISC-V port with supporting both COND_* and COND_LEN_*. And also, Bootstrap and Regression on X86 passed. OK for trunk? gcc/ChangeLog: * internal-fn.cc (get_len_internal_fn): New function. (DEF_INTERNAL_COND_FN): Ditto. (DEF_INTERNAL_SIGNED_COND_FN): Ditto. * internal-fn.h (get_len_internal_fn): Ditto. * tree-vect-stmts.cc (vectorizable_call): Add CALL auto-vectorization.
2023-08-08tree-optimization/110924 - fix vop liveness for noreturn const CFG partsRichard Biener4-15/+44
The virtual operand live problem used by sinking assumes we have virtual uses at each end point of the CFG but as shown in the PR this isn't true for parts for example ending in __builtin_unreachable. The following removes the optimization made possible by this and now requires marking backedges. PR tree-optimization/110924 * tree-ssa-live.h (virtual_operand_live): Update comment. * tree-ssa-live.cc (virtual_operand_live::get_live_in): Remove optimization, look at each predecessor. * tree-ssa-sink.cc (pass_sink_code::execute): Mark backedges. * gcc.dg/torture/pr110924.c: New testcase.
2023-08-08RISC-V: Fix a bug that causes an error insn.yulong7-3/+134
I test the following rvv intrinsics. vint64m1_t test_vslide1up_vx_i64m1_m(vbool64_t mask, vint64m1_t src, int64_t value, size_t vl) { return __riscv_vslide1up_vx_i64m1_m(mask, src, value, vl); } And I got an error info,t hat is error: unrecognizable insn:(insn 17 16 18 2 (set (reg:RVVMIDI 134 [ _1 ])(if_then_else:RVVMIDI (unspec:RVVMF64BI [(reg/v:SI 142 [ vl ])(const_int 2 [x2])(const_int 日 [o])(reg:SI 66 vl)(reg:SI 67 vtype)] UNSPEC_VPREDICATE (vec_merge:RVVMIDI (reg:RVVMIDI 134 [ _1 ])(unspec:RVVMIDI [(reg:sI 日 zero)] UNSPEC_VUNDEF) (reg/v:RVVMF64BI 137 [ mask ])) (unspec:RVVM1DI[(reg:sI 日 zero)] UNSPEC_VUNDEF))) This patch fix it. gcc/ChangeLog: * config/riscv/riscv-v.cc (slide1_sew64_helper): Modify. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/vslide1down-1.c: New test. * gcc.target/riscv/rvv/base/vslide1down-2.c: New test. * gcc.target/riscv/rvv/base/vslide1down-3.c: New test. * gcc.target/riscv/rvv/base/vslide1up-1.c: New test. * gcc.target/riscv/rvv/base/vslide1up-2.c: New test. * gcc.target/riscv/rvv/base/vslide1up-3.c: New test.
2023-08-08rtl-optimization/110869 Fix tests cmp-mem-const-*.c for sparcStefan Schulze Frielinghaus6-10/+18
This fixes the rather new tests cmp-mem-const-{1,2,3,4,5,6}.c for sparc. For -1 and -2 we need at least optimization level 2 on sparc. For the sake of homogeneity, change all test cases to -O2. For -3 and -4 we do not end up with a comparison of memory and a constant, and finally for -5 and -6 the constants are reduced by a prior optimization which means there is nothing left to do. Thus excluding sparc from those tests. gcc/testsuite/ChangeLog: PR rtl-optimization/110869 * gcc.dg/cmp-mem-const-1.c: Use optimization level 2. * gcc.dg/cmp-mem-const-2.c: Dito. * gcc.dg/cmp-mem-const-3.c: Exclude sparc from this test. * gcc.dg/cmp-mem-const-4.c: Dito. * gcc.dg/cmp-mem-const-5.c: Dito. * gcc.dg/cmp-mem-const-6.c: Dito.
2023-08-08RISC-V: Support neg VLS auto-vectorizationJuzhe-Zhong4-5/+91
#include "riscv_vector.h" #define DEF_OP_V(PREFIX, NUM, TYPE, OP) \ void __attribute__ ((noinline, noclone)) \ PREFIX##_##TYPE##NUM (TYPE *restrict a, TYPE *restrict b) \ { \ for (int i = 0; i < NUM; ++i) \ a[i] = OP b[i]; \ } DEF_OP_V (neg, 16, int32_t, -) After this patch: neg_int32_t16: vsetivli zero,16,e32,mf2,ta,ma vle32.v v1,0(a1) vneg.v v1,v1 vse32.v v1,0(a0) ret gcc/ChangeLog: * config/riscv/autovec-vls.md (<optab><mode>2): Add VLS neg. * config/riscv/vector.md: Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vls/def.h: Ditto. * gcc.target/riscv/rvv/autovec/vls/neg-1.c: New test.
2023-08-08RISC-V: Support VLS shift vectorizationJuzhe-Zhong8-7/+358
After this patch, this following case will be well optimized: void __attribute__ ((noinline, noclone)) \ PREFIX##_##TYPE##NUM (TYPE *restrict a, TYPE *restrict b, TYPE *restrict c) \ { \ for (int i = 0; i < NUM; ++i) \ a[i] = b[i] OP c[i]; \ } DEF_OP_VV (shift, 16, int32_t, >>) ASM: shift_int32_t16: vsetivli zero,16,e32,mf2,ta,ma vle32.v v1,0(a1) vle32.v v2,0(a2) vsra.vv v1,v1,v2 vse32.v v1,0(a0) ret gcc/ChangeLog: * config/riscv/autovec.md: Add VLS shift. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vls/def.h: Add VLS shift. * gcc.target/riscv/rvv/autovec/vls/shift-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-2.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-3.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-4.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-5.c: New test. * gcc.target/riscv/rvv/autovec/vls/shift-6.c: New test.
2023-08-08Daily bump.GCC Administrator30-1/+1084
2023-08-08RISC-V: Support VLS basic operation auto-vectorizationJuzhe-Zhong21-83/+1217
This patch support VLS modes auto-vectorization to enhance VLA auto-vectorization when niters is known. Consider this following case: void __attribute__ ((noinline, noclone)) \ PREFIX##_##TYPE##NUM (TYPE *__restrict a, TYPE *__restrict b, TYPE *__restrict c) \ { \ for (int i = 0; i < NUM; ++i) \ a[i] = b[i] OP c[i]; \ } DEF_OP_VV (plus, 16, int8_t, +) Before this patch: plus_int8_t16(signed char*, signed char*, signed char*): li a5,16 csrr a4,vlenb bleu a5,a4,.L2 mv a5,a4 .L2: vsetvli zero,a5,e8,m1,ta,ma vle8.v v2,0(a1) vle8.v v1,0(a2) vsetvli a4,zero,e8,m1,ta,ma vadd.vv v1,v1,v2 vsetvli zero,a5,e8,m1,ta,ma vse8.v v1,0(a0) ret After this patch: plus_int8_t16: vsetivli zero,16,e8,m1,ta,ma vle8.v v1,0(a2) vle8.v v2,0(a1) vadd.vv v1,v1,v2 vse8.v v1,0(a0) ret gcc/ChangeLog: * config/riscv/autovec-vls.md (<optab><mode>3): Add VLS modes. * config/riscv/vector-iterators.md: Ditto. * config/riscv/vector.md: Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vls/def.h: Add basic operations. * gcc.target/riscv/rvv/autovec/vls/and-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/and-2.c: New test. * gcc.target/riscv/rvv/autovec/vls/and-3.c: New test. * gcc.target/riscv/rvv/autovec/vls/div-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/ior-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/ior-2.c: New test. * gcc.target/riscv/rvv/autovec/vls/ior-3.c: New test. * gcc.target/riscv/rvv/autovec/vls/max-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/min-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/minus-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/minus-2.c: New test. * gcc.target/riscv/rvv/autovec/vls/minus-3.c: New test. * gcc.target/riscv/rvv/autovec/vls/mod-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/mult-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/plus-1.c: New test. * gcc.target/riscv/rvv/autovec/vls/plus-2.c: New test. * gcc.target/riscv/rvv/autovec/vls/plus-3.c: New test.
2023-08-07libstdc++: Fix incorrect use of abs and log10 in std::format [PR110860]Jonathan Wakely1-3/+14
The std::formatter implementation for floating-point types uses __builtin_abs and __builtin_log10 to avoid including all of <cmath>, but those functions are not generic. The result of abs(2e304) is -INT_MIN which is undefined, and then log10(INT_MIN) is NaN. As well as being undefined, we fail to grow the buffer correctly, and then loop more times than needed to allocate a buffer and try formatting the value into it again. We can use if-constexpr to choose the correct form of log10 to use for the type, and avoid using abs entirely. This avoids the undefined behaviour and should mean we only reallocate and retry std::to_chars once. libstdc++-v3/ChangeLog: PR libstdc++/110860 * include/std/format (__formatter_fp::format): Do not use __builtin_abs and __builtin_log10 with arbitrary floating-point types.
2023-08-07libstdc++: Constrain __format::_Iter_sink for contiguous iterators [PR110917]Jonathan Wakely2-0/+101
We can't write to a span<_CharT> if the contiguous iterator has a value type that isn't _CharT. libstdc++-v3/ChangeLog: PR libstdc++/110917 * include/std/format (__format::_Iter_sink<CharT, OutIter>): Constrain partial specialization for contiguous iterators to require the value type to be CharT. * testsuite/std/format/functions/format_to.cc: New test.
2023-08-07i386: Fix grammar typo in diagnosticJonathan Wakely1-1/+1
gcc/ChangeLog: * config/i386/i386.cc (ix86_invalid_conversion): Fix grammar.
2023-08-07libstdc++: Fix past-the-end increment in std::format [PR110862]Jonathan Wakely2-1/+16
At the end of a replacement field we should check that the closing brace is actually present before incrementing past it. libstdc++-v3/ChangeLog: PR libstdc++/110862 * include/std/format (_Scanner::_M_on_replacement_field): Check for expected '}' before incrementing iterator. * testsuite/std/format/string.cc: Check "{0:{0}" format string.
2023-08-07toplevel: Makefile.def: add install-strip dependency on libsframeIndu Bhagat2-2/+6
As noted in PR libsframe/30014 - FTBFS: install-strip fails because bfdlib relinks and fails to find libsframe, the install time dependencies of libbfd need to be updated. ChangeLog: * Makefile.def: Reflect that libsframe needs to installed before libbfd. Reorder a bit to better track libsframe dependencies. * Makefile.in: Regenerate.
2023-08-07bfd: linker: merge .sframe sectionsIndu Bhagat2-0/+15
The linker merges all the input .sframe sections. When merging, the linker verifies that all the input .sframe sections have the same abi/arch. The linker uses libsframe library to perform key actions on the .sframe sections - decode, read, and create output data. This implies buildsystem changes to make and install libsframe before libbfd. The linker places the output .sframe section in a new segment of its own: PT_GNU_SFRAME. A new segment is not added, however, if the generated .sframe section is empty. When a section is discarded from the final link, the corresponding entries in the .sframe section for those functions are also deleted. The linker sorts the SFrame FDEs on start address by default and sets the SFRAME_F_FDE_SORTED flag in the .sframe section. This patch also adds support for generation of SFrame unwind information for the .plt* sections on x86_64. SFrame unwind info is generated for IBT enabled PLT, lazy/non-lazy PLT. The existing linker option --no-ld-generated-unwind-info has been adapted to include the control of whether .sframe unwind information will be generated for the linker generated sections like PLT. Changes to the linker script have been made as necessary. ChangeLog: * Makefile.def: Add install dependency on libsframe for libbfd. * Makefile.in: Regenerated.
2023-08-07libtool.m4: augment symcode for Solaris 11Nick Alcock19-19/+19
This reports common symbols like GNU nm, via a type code of 'C'. ChangeLog: * libtool.m4 (lt_cv_sys_global_symbol_pipe): Augment symcode for Solaris 11. gcc/ChangeLog: * configure: Regenerate. libatomic/ChangeLog: * configure: Regenerate. libbacktrace/ChangeLog: * configure: Regenerate. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * configure: Regenerate. libgfortran/ChangeLog: * configure: Regenerate. libgm2/ChangeLog: * configure: Regenerate. libgomp/ChangeLog: * configure: Regenerate. libitm/ChangeLog: * configure: Regenerate. libobjc/ChangeLog: * configure: Regenerate. libphobos/ChangeLog: * configure: Regenerate. libquadmath/ChangeLog: * configure: Regenerate. libsanitizer/ChangeLog: * configure: Regenerate. libssp/ChangeLog: * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate. libvtv/ChangeLog: * configure: Regenerate. lto-plugin/ChangeLog: * configure: Regenerate. zlib/ChangeLog: * configure: Regenerate.
2023-08-07PKG_CHECK_MODULES: Properly check if $pkg_cv_[]$1[]_LIBS worksH.J. Lu1-4/+6
There is no need to check $pkg_cv_[]$1[]_LIBS works if package check failed. config/ChangeLog: * pkg.m4 (PKG_CHECK_MODULES): Use AC_TRY_LINK only if $pkg_failed = no.
2023-08-07PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS worksH.J. Lu1-0/+6
It is quite normal to have headers without library on multilib OSes. Add AC_TRY_LINK to PKG_CHECK_MODULES to check if $pkg_cv_[]$1[]_LIBS works. config/ChangeLog: * pkg.m4 (PKG_CHECK_MODULES): Add AC_TRY_LINK to check if $pkg_cv_[]$1[]_LIBS works.
2023-08-07Deprecate a.out support for NetBSD targets.John Ericson5-17/+7
As discussed previously, a.out support is now quite deprecated, and in some cases removed, in both Binutils itself and NetBSD, so this legacy default makes little sense. `netbsdelf*` and `netbsdaout*` still work allowing the user to be explicit about there choice. Additionally, the configure script warns about the change as Nick Clifton requested. One possible concern was the status of NetBSD on NS32K, where only a.out was supported. But per [1] NetBSD has removed support, and if it were to come back, it would be with ELF. The binutils implementation is therefore marked obsolete, per the instructions in the last message. With that patch and this one applied, I have confirmed the following: --target=i686-unknown-netbsd --target=i686-unknown-netbsdelf builds completely --target=i686-unknown-netbsdaout properly fails because target is deprecated. --target=vax-unknown-netbsdaout builds completely except for gas, where the target is deprecated. [1]: https://mail-index.netbsd.org/tech-toolchain/2021/07/19/msg004025.html config/ChangeLog: * picflag.m4: Simplify SHmedia NetBSD match by presuming ELF. gcc/ChangeLog: * configure: Regenerate. libada/ChangeLog: * configure: Regenerate. libgcc/ChangeLog: * configure: Regenerate. libiberty/ChangeLog: * configure: Regenerate.
2023-08-07PR27116, Spelling errors found by Debian style checkerAlan Modra1-1/+1
config/ChangeLog: * override.m4: Correct comment grammar.
2023-08-07egrep in binutilsAlan Modra6-12/+14
Apparently some distros have a nagging egrep that helpfully tells you egrep is deprecated and to use "grep -E". The nag message causes a ld testsuite failure. What's more the advice isn't that good. The "-E" flag may not be available with older versions of grep. This patch fixes bare invocation of egrep within binutils, replacing it with the autoconf $EGREP or with grep. config/ChangeLog: * lib-ld.m4 (AC_LIB_PROG_LD_GNU): Require AC_PROG_EGREP and invoke $EGREP. (AC_LIB_PROG_LD): Likewise. gcc/ChangeLog: * configure: Regenerate. intl/ChangeLog: * configure: Regenerate. libcpp/ChangeLog: * configure: Regenerate. libgcc/ChangeLog: * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate.
2023-08-07Add support for the haiku operating systemAlexander von Gluck IV21-31/+31
These are the os support patches we have been grooming and maintaining for quite a few years over on git.haiku-os.org. All of these architectures are working and most have been stable for quite some time. ChangeLog: * configure: Regenerate. * configure.ac: Add Haiku to list of ELF OSes * libtool.m4: Update sys_lib_dlsearch_path_spec on Haiku. gcc/ChangeLog: * configure: Regenerate. libatomic/ChangeLog: * configure: Regenerate. libbacktrace/ChangeLog: * configure: Regenerate. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * configure: Regenerate. libgfortran/ChangeLog: * configure: Regenerate. libgm2/ChangeLog: * configure: Regenerate. libgomp/ChangeLog: * configure: Regenerate. libitm/ChangeLog: * configure: Regenerate. libobjc/ChangeLog: * configure: Regenerate. libphobos/ChangeLog: * configure: Regenerate. libquadmath/ChangeLog: * configure: Regenerate. libsanitizer/ChangeLog: * configure: Regenerate. libssp/ChangeLog: * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate. libvtv/ChangeLog: * configure: Regenerate. lto-plugin/ChangeLog: * configure: Regenerate. zlib/ChangeLog: * configure: Regenerate.
2023-08-07libtool.m4: fix the NM="/nm/over/here -B/option/with/path" caseNick Alcock19-137/+251
My previous nm patch handled all cases but one -- if the user set NM in the environment to a path which contained an option, libtool's nm detection tries to run nm against a copy of nm with the options in it: e.g. if NM was set to "nm --blargle", and nm was found in /usr/bin, the test would try to run "/usr/bin/nm --blargle /usr/bin/nm --blargle". This is unlikely to be desirable: in this case we should run "/usr/bin/nm --blargle /usr/bin/nm". Furthermore, as part of this nm has to detect when the passed-in $NM contains a path, and in that case avoid doing a path search itself. This too was thrown off if an option contained something that looked like a path, e.g. NM="nm -B../prev-gcc"; libtool then tries to run "nm -B../prev-gcc nm" which rarely works well (and indeed it looks to see whether that nm exists, finds it doesn't, and wrongly concludes that nm -p or whatever does not work). Fix all of these by clipping all options (defined as everything including and after the first " -") before deciding whether nm contains a path (but not using the clipped value for anything else), and then removing all options from the path-modified nm before looking to see whether that nm existed. NM=my-nm now does a path search and runs e.g. /usr/bin/my-nm -B /usr/bin/my-nm NM=/usr/bin/my-nm now avoids a path search and runs e.g. /usr/bin/my-nm -B /usr/bin/my-nm NM="my-nm -p../wombat" now does a path search and runs e.g. /usr/bin/my-nm -p../wombat -B /usr/bin/my-nm NM="../prev-binutils/new-nm -B../prev-gcc" now avoids a path search: ../prev-binutils/my-nm -B../prev-gcc -B ../prev-binutils/my-nm This seems to be all combinations, including those used by GCC bootstrap (which, before this commit, fails to bootstrap when configured --with-build-config=bootstrap-lto, because the lto plugin is now using --export-symbols-regex, which requires libtool to find a working nm, while also using -B../prev-gcc to point at the lto plugin associated with the GCC just built.) Regenerate all affected configure scripts. ChangeLog: * libtool.m4 (LT_PATH_NM): Handle user-specified NM with options, including options containing paths. gcc/ChangeLog: * configure: Regenerate. libatomic/ChangeLog: * configure: Regenerate. libbacktrace/ChangeLog: * configure: Regenerate. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * configure: Regenerate. libgfortran/ChangeLog: * configure: Regenerate. libgm2/ChangeLog: * configure: Regenerate. libgomp/ChangeLog: * configure: Regenerate. libitm/ChangeLog: * configure: Regenerate. libobjc/ChangeLog: * configure: Regenerate. libphobos/ChangeLog: * configure: Regenerate. libquadmath/ChangeLog: * configure: Regenerate. libsanitizer/ChangeLog: * configure: Regenerate. libssp/ChangeLog: * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate. libvtv/ChangeLog: * configure: Regenerate. lto-plugin/ChangeLog: * configure: Regenerate. zlib/ChangeLog: * configure: Regenerate.
2023-08-07libtool.m4: fix nm BSD flag detectionNick Alcock20-842/+863
Libtool needs to get BSD-format (or MS-format) output out of the system nm, so that it can scan generated object files for symbol names for -export-symbols-regex support. Some nms need specific flags to turn on BSD-formatted output, so libtool checks for this in its AC_PATH_NM. Unfortunately the code to do this has a pair of interlocking flaws: - it runs the test by doing an nm of /dev/null. Some platforms reasonably refuse to do an nm on a device file, but before now this has only been worked around by assuming that the error message has a specific textual form emitted by Tru64 nm, and that getting this error means this is Tru64 nm and that nm -B would work to produce BSD-format output, even though the test never actually got anything but an error message out of nm -B. This is fixable by nm'ing *nm itself* (since we necessarily have a path to it). - the test is entirely skipped if NM is set in the environment, on the grounds that the user has overridden the test: but the user cannot reasonably be expected to know that libtool wants not only nm but also flags forcing BSD-format output. Worse yet, one such "user" is the top-level Cygnus configure script, which neither tests for nor specifies any BSD-format flags. So platforms needing BSD-format flags always fail to set them when run in a Cygnus tree, breaking -export-symbols-regex on such platforms. Libtool also needs to augment $LD on some platforms, but this is done unconditionally, augmenting whatever the user specified: the nm check should do the same. One wrinkle: if the user has overridden $NM, a path might have been provided: so we use the user-specified path if there was one, and otherwise do the path search as usual. (If the nm specified doesn't work, this might lead to a few extra pointless path searches -- but the test is going to fail anyway, so that's not a problem.) (Tested with NM unset, and set to nm, /usr/bin/nm, my-nm where my-nm is a symlink to /usr/bin/nm on the PATH, and /not-on-the-path/my-nm where *that* is a symlink to /usr/bin/nm.) ChangeLog: * libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided NM, if there is one. Run nm on itself, not on /dev/null, to avoid errors from nms that refuse to work on non-regular files. Remove other workarounds for this problem. Strip out blank lines from the nm output. fixincludes/ChangeLog: * configure: Regenerate. gcc/ChangeLog: * configure: Regenerate. libatomic/ChangeLog: * configure: Regenerate. libbacktrace/ChangeLog: * configure: Regenerate. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * configure: Regenerate. libgfortran/ChangeLog: * configure: Regenerate. libgm2/ChangeLog: * configure: Regenerate. libgomp/ChangeLog: * configure: Regenerate. libitm/ChangeLog: * configure: Regenerate. libobjc/ChangeLog: * configure: Regenerate. libphobos/ChangeLog: * configure: Regenerate. libquadmath/ChangeLog: * configure: Regenerate. libsanitizer/ChangeLog: * configure: Regenerate. libssp/ChangeLog: * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate. libvtv/ChangeLog: * configure: Regenerate. lto-plugin/ChangeLog: * configure: Regenerate. zlib/ChangeLog: * configure: Regenerate.
2023-08-07configure: reinstate 32b PA-RISC HP-UX target in toplevelArsen Arsenović2-0/+20
The Binutils still support this target. ChangeLog: * configure.ac: Reinstate 32b PA-RISC HP-UX targets * configure: Regenerate.
2023-08-07Pass PKG_CONFIG_PATH down from top-level MakefileSimon Marchi4-0/+9
[Sending to binutils, gdb-patches and gcc-patches, since it touches the top-level Makefile/configure] I have my debuginfod library installed in a non-standard location (/opt/debuginfod), which requires me to set PKG_CONFIG_PATH=/opt/debuginfod/lib/pkg-config. If I just set it during configure: $ PKG_CONFIG_PATH=/opt/debuginfod/lib/pkg-config ./configure --with-debuginfod $ make or $ ./configure --with-debuginfod PKG_CONFIG_PATH=/opt/debuginfod/lib/pkg-config $ make Then PKG_CONFIG_PATH is only present (and ignored) during the top-level configure. When running make (which runs gdb's and binutils' configure), PKG_CONFIG_PATH is not set, which results in their configure script not finding the library: checking for libdebuginfod >= 0.179... no configure: error: "--with-debuginfod was given, but libdebuginfod is missing or unusable." Change the top-level configure/Makefile system to capture the value passed when configuring the top-level and pass it down to subdirectories (similar to CFLAGS, LDFLAGS, etc). I don't know much about the top-level build system, so I really don't know if I did this correctly. The changes are: - Use AC_SUBST(PKG_CONFIG_PATH) in configure.ac, so that @PKG_CONFIG_PATH@ gets replaced with the actual PKG_CONFIG_PATH value in config files (i.e. Makefile) - Add a PKG_CONFIG_PATH Makefile variable in Makefile.tpl, initialized to @PKG_CONFIG_PATH@ - Add PKG_CONFIG_PATH to HOST_EXPORTS in Makefile.tpl, which are the variables set when running the sub-configures I initially added PKG_CONFIG_PATH to flags_to_pass, in Makefile.def, but I don't think it's needed. AFAIU, this defines the flags to pass down when calling "make" in subdirectories. We only need PKG_CONFIG_PATH to be passed down during configure. After that, it's captured in gdb/config.status, so even if a "make" causes a re-configure later (because gdb/configure has changed, for example), the PKG_CONFIG_PATH value will be remembered. Change-Id: I91138dfca41c43b05e53e445f62e4b27882536bf ChangeLog: * configure.ac: Add AC_SUBST(PKG_CONFIG_PATH). * configure: Re-generate. * Makefile.tpl (HOST_EXPORTS): Pass PKG_CONFIG_PATH. (PKG_CONFIG_PATH): New. * Makefile.in: Re-generate.
2023-08-07Disable year 2038 support on 32-bit hosts by defaultLuis Machado2-0/+40
With a recent import of gnulib, code has been pulled that tests and enables 64-bit time_t by default on 32-bit hosts that support it. Although gdb can use the gnulib support, bfd doesn't use gnulib and currently doesn't do these checks. As a consequence, if we have a 32-bit host that supports 64-bit time_t, we'll have a mismatch between gdb's notion of time_t and bfd's notion of time_t. This will lead to mismatches in the struct stat size, leading to memory corruption and crashes. This patch disables the year 2038 check for now, which makes things work reliably again. I'd consider this a temporary fix until we have proper bfd checks for the year 2038, if it makes sense. 64-bit hosts seems to be more common these days, so I'm not sure how important it is to have this support enabled and how soon we want to enable it. Thoughts? ChangeLog: * configure.ac: Disable year2038 by default on 32-bit hosts. * configure: Regenerate.
2023-08-07gprofng: a new GNU profilerVladimir Mezentsev7-0/+744
ChangeLog: * Makefile.def: Add gprofng module. * configure.ac: Add --enable-gprofng option. * Makefile.in: Regenerate. * configure: Regenerate. include/ChangeLog: * collectorAPI.h: New file. * libcollector.h: New file. * libfcollector.h: New file.
2023-08-07add --enable-default-compressed-debug-sections-algorithm configure optionMartin Liska2-0/+19
ChangeLog: * configure.ac: Add --enable-default-compressed-debug-sections-algorithm. * configure: Regenerate.
2023-08-07configure: require libzstd >= 1.4.0Christophe Lyon1-1/+1
gas uses ZSTD_compressStream2 which is only available with libzstd >= 1.4.0, leading to build errors when an older version is installed. This patch updates the check libzstd presence to check its version is >= 1.4.0. However, since gas seems to be the only component requiring such a recent version this may imply that we disable ZSTD support for all components although some would still benefit from an older version. I ran 'autoreconf -f' in all directories containing a configure.ac file, using vanilla autoconf-2.69 and automake-1.15.1. I noticed several errors from autoheader in readline, as well as warnings in intl, but they are unrelated to this patch. This should fix some of the buildbots. OK for trunk? Thanks, Christophe config/ChangeLog: * zstd.m4: Add minimum version requirement of 1.4.0.
2023-08-07binutils, gdb: support zstd compressed debug sectionsFangrui Song3-0/+36
PR29397 PR29563: Add new configure option --with-zstd which defaults to auto. If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support zstd compressed debug sections for most tools. * bfd: for addr2line, objdump --dwarf, gdb, etc * gas: support --compress-debug-sections=zstd * ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd * objcopy: support ELFCOMPRESS_ZSTD input for --decompress-debug-sections and --compress-debug-sections=zstd * gdb: support ELFCOMPRESS_ZSTD input. The bfd change references zstd symbols, so gdb has to link against -lzstd in this patch. If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error. We can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this is too heavyweight, so don't do it for now. ``` % ld/ld-new a.o ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support ... % ld/ld-new a.o --compress-debug-sections=zstd ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support % binutils/objcopy --compress-debug-sections=zstd a.o b.o binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support % binutils/objcopy b.o --decompress-debug-sections binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support ... ``` config/ChangeLog: * zstd.m4: New file. ChangeLog: * configure: Regenerate. * configure.ac: Add --with-zstd.
2023-08-07toplevel: Recover tilegx/tilepro targetsArsen Arsenović2-2/+8
These are still supported in Binutils. ChangeLog: * configure: Regenerate. * configure.ac: Recover tilegx/tilepro targets.
2023-08-07GCC: Check if AR works with --plugin and rcH.J. Lu22-61/+430
AR from older binutils doesn't work with --plugin and rc: [hjl@gnu-cfl-2 bin]$ touch foo.c [hjl@gnu-cfl-2 bin]$ ar --plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so rc libfoo.a foo.c [hjl@gnu-cfl-2 bin]$ ./ar --plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so rc libfoo.a foo.c ./ar: no operation specified [hjl@gnu-cfl-2 bin]$ ./ar --version GNU ar (Linux/GNU Binutils) 2.29.51.0.1.20180112 Copyright (C) 2018 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) any later version. This program has absolutely no warranty. [hjl@gnu-cfl-2 bin]$ Check if AR works with --plugin and rc before passing --plugin to AR and RANLIB. ChangeLog: * configure: Regenerated. * libtool.m4 (_LT_CMD_OLD_ARCHIVE): Check if AR works with --plugin and rc before enabling --plugin. config/ChangeLog: * gcc-plugin.m4 (GCC_PLUGIN_OPTION): Check if AR works with --plugin and rc before enabling --plugin. gcc/ChangeLog: * configure: Regenerate. libatomic/ChangeLog: * configure: Regenerate. libbacktrace/ChangeLog: * configure: Regenerate. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * configure: Regenerate. libgfortran/ChangeLog: * configure: Regenerate. libgm2/ChangeLog: * configure: Regenerate. libgomp/ChangeLog: * configure: Regenerate. libiberty/ChangeLog: * configure: Regenerate. libitm/ChangeLog: * configure: Regenerate. libobjc/ChangeLog: * configure: Regenerate. libphobos/ChangeLog: * configure: Regenerate. libquadmath/ChangeLog: * configure: Regenerate. libsanitizer/ChangeLog: * configure: Regenerate. libssp/ChangeLog: * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate. libvtv/ChangeLog: * configure: Regenerate. lto-plugin/ChangeLog: * configure: Regenerate. zlib/ChangeLog: * configure: Regenerate.
2023-08-07Sync with binutils: GCC: Pass --plugin to AR and RANLIBH.J. Lu28-49/+621
Sync with binutils for building binutils with LTO: 50ad1254d50 GCC: Pass --plugin to AR and RANLIB Detect GCC LTO plugin. Pass --plugin to AR and RANLIB to support LTO build. ChangeLog: * Makefile.tpl (AR): Add @AR_PLUGIN_OPTION@ (RANLIB): Add @RANLIB_PLUGIN_OPTION@. * configure.ac: Include config/gcc-plugin.m4. AC_SUBST AR_PLUGIN_OPTION and RANLIB_PLUGIN_OPTION. * libtool.m4 (_LT_CMD_OLD_ARCHIVE): Pass --plugin to AR and RANLIB if possible. * Makefile.in: Regenerated. * configure: Likewise. config/ChangeLog: * gcc-plugin.m4 (GCC_PLUGIN_OPTION): New. libiberty/ChangeLog: * Makefile.in (AR): Add @AR_PLUGIN_OPTION@ (RANLIB): Add @RANLIB_PLUGIN_OPTION@. (configure_deps): Depend on ../config/gcc-plugin.m4. * configure.ac: AC_SUBST AR_PLUGIN_OPTION and RANLIB_PLUGIN_OPTION. * aclocal.m4: Regenerated. * configure: Likewise. zlib/ChangeLog: * configure: Regenerated. gcc/ChangeLog: * configure: Regenerate. libatomic/ChangeLog: * configure: Regenerate. libbacktrace/ChangeLog: * configure: Regenerate. libcc1/ChangeLog: * configure: Regenerate. libffi/ChangeLog: * configure: Regenerate. libgfortran/ChangeLog: * configure: Regenerate. libgm2/ChangeLog: * configure: Regenerate. libgomp/ChangeLog: * configure: Regenerate. libitm/ChangeLog: * configure: Regenerate. libobjc/ChangeLog: * configure: Regenerate. libphobos/ChangeLog: * configure: Regenerate. libquadmath/ChangeLog: * configure: Regenerate. libsanitizer/ChangeLog: * configure: Regenerate. libssp/ChangeLog: * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate. libvtv/ChangeLog: * configure: Regenerate. lto-plugin/ChangeLog: * configure: Regenerate.
2023-08-07gcc-4.5 build fixesAlan Modra1-2/+0
Trying to build binutils with an older gcc currently fails. Working around these gcc bugs is not onerous so let's fix them. include/ChangeLog: * xtensa-dynconfig.h (xtensa_isa_internal): Delete unnecessary forward declaration.
2023-08-07PR29961, plugin-api.h: "Could not detect architecture endianess"Alan Modra1-22/+23
Found when attempting to build binutils on sparc sunos-5.8 where sys/byteorder.h defines _BIG_ENDIAN but not any of the BYTE_ORDER variants. This patch adds the extra tests to cope with the old machine, and tidies the header a little. include/ChangeLog: * plugin-api.h: When handling non-gcc or gcc < 4.6.0 include necessary header files before testing macros. Make more use of #elif. Test _LITTLE_ENDIAN and _BIG_ENDIAN in final tests.
2023-08-07toplevel: Substitute GDCFLAGS instead of using CFLAGSArsen Arsenović1-1/+1
r14-2875-g1ed21e23d6d4da ("Use substituted GDCFLAGS") already implemented this change, but only on the generated file rather than in the template it is generated from. ChangeLog: * Makefile.tpl: Substitute @GDCFLAGS@ instead of using $(CFLAGS).
2023-08-07[committed][RISC-V]Don't reject constants in cmov conditionJeff Law1-1/+2
This test is too aggressive. Constants have VOIDmode, so we need to let the through this phase of conditional move support. Fixes several missed conditional moves with the trunk. gcc/ * config/riscv/riscv.cc (riscv_expand_conditional_move): Allow VOIDmode operands to conditional before canonicalization.
2023-08-07cprop_hardreg: Allow propagation of stack pointer in more cases.Manolis Tsamis1-33/+23
The stack pointer propagation fix 736f8fd3 turned out to be more restrictive than needed by rejecting propagation of the stack pointer when REG_POINTER didn't match. This commit removes this check: When the stack pointer is propagated it is fine for this to result in REG_POINTER becoming true from false, which is what the original code checked. This simplification makes the previously introduced function maybe_copy_reg_attrs obsolete and the logic can be inlined at the call sites, as it was before 736f8fd3. gcc/ChangeLog: * regcprop.cc (maybe_copy_reg_attrs): Remove unnecessary function. (find_oldest_value_reg): Inline stack_pointer_rtx check. (copyprop_hardreg_forward_1): Inline stack_pointer_rtx check.
2023-08-07MAINTAINERS: Add myself as a BPF port reviewerDavid Faust1-1/+1
ChangeLog: * MAINTAINERS: Add the BPF port to my reviewer listing.
2023-08-07ipa-sra: Don't consider CLOBBERS as writes preventing splittingMartin Jambor4-6/+94
When IPA-SRA detects whether a parameter passed by reference is written to, it does not special case CLOBBERs which means it often bails out unnecessarily, especially when dealing with C++ destructors. Fixed by the obvious continue in the two relevant loops and by adding a simple function that marks the clobbers in the transformation code as statements to be removed. gcc/ChangeLog: 2023-08-04 Martin Jambor <mjambor@suse.cz> PR ipa/110378 * ipa-param-manipulation.h (class ipa_param_body_adjustments): New members get_ddef_if_exists_and_is_used and mark_clobbers_dead. * ipa-sra.cc (isra_track_scalar_value_uses): Ignore clobbers. (ptr_parm_has_nonarg_uses): Likewise. * ipa-param-manipulation.cc (ipa_param_body_adjustments::get_ddef_if_exists_and_is_used): New. (ipa_param_body_adjustments::mark_dead_statements): Move initial checks to get_ddef_if_exists_and_is_used. (ipa_param_body_adjustments::mark_clobbers_dead): New. (ipa_param_body_adjustments::common_initialization): Call mark_clobbers_dead when splitting. gcc/testsuite/ChangeLog: 2023-07-31 Martin Jambor <mjambor@suse.cz> PR ipa/110378 * g++.dg/ipa/pr110378-1.C: New test.
2023-08-07[committed] [RISC-V] Handle more cases in riscv_expand_conditional_moveRaphael Zinsly2-4/+42
As I've mentioned in the main zicond thread, Ventana has had patches that support more cases by first emitting a suitable scc instruction essentially as a canonicalization step of the condition for zicond. For example if we have (set (target) (if_then_else (op (reg1) (reg2)) (true_value) (false_value))) The two register comparison isn't handled by zicond directly. But we can generate something like this instead (set (temp) (op (reg1) (reg2))) (set (target) (if_then_else (op (temp) (const_int 0)) (true_value) (false_value) Then let the remaining code from Xiao handle the true_value/false_value to make sure it's zicond compatible. This is primarily Raphael's work. My involvement has been mostly to move it from its original location (in the .md file) into the expander function and fix minor problems with the FP case. gcc/ * config/riscv/riscv.cc (riscv_expand_int_scc): Add invert_ptr as an argument and pass it to riscv_emit_int_order_test. (riscv_expand_conditional_move): Handle cases where the condition is not EQ/NE or the second argument to the conditional is not (const_int 0). * config/riscv/riscv-protos.h (riscv_expand_int_scc): Update prototype. Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
2023-08-07MATCH: [PR109959] `(uns <= 1) & uns` could be optimized to `uns == 1`Andrew Pinski6-6/+117
I noticed while looking into some code generation of bitmap_single_bit_set_p, that sometimes: ``` if (uns > 1) return 0; return uns == 1; ``` Would not optimize down to just: ``` return uns == 1; ``` In this case, VRP likes to change `a == 1` into `(bool)a` if a has a range of [0,1] due to `a <= 1` side of the branch. We might end up with this similar code even without VRP, in the case of builtin-sprintf-warn-23.c (and Wrestrict.c), we had: ``` if (s < 0 || 1 < s) s = 0; ``` Which is the same as `s = ((unsigned)s) <= 1 ? s : 0`; So we should be able to catch that also. This adds 2 patterns to catch `(uns <= 1) & uns` and `(uns > 1) ? 0 : uns` and convert those into: `(convert) uns == 1`. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/109959 gcc/ChangeLog: * match.pd (`(a > 1) ? 0 : (cast)a`, `(a <= 1) & (cast)a`): New patterns. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/builtin-sprintf-warn-23.c: Remove xfail. * c-c++-common/Wrestrict.c: Update test and remove some xfail. * gcc.dg/tree-ssa/cmpeq-1.c: New test. * gcc.dg/tree-ssa/cmpeq-2.c: New test. * gcc.dg/tree-ssa/cmpeq-3.c: New test.
2023-08-07Use RPO order for sinkingRichard Biener1-14/+5
The following makes us use RPO order instead of walking post-dominators. This ensures we visit a block before any predecessors. I've seen some extra sinking because of this in a larger testcase but failed to reduce a smaller one (processing of post-dominator sons is unordered so I failed to have "luck"). * tree-ssa-sink.cc (pass_sink_code::execute): Do not calculate post-dominators. Calculate RPO on the inverted graph and process blocks in that order.
2023-08-07Fix ICE in rtl check when bootstrap.liuhongt3-6/+6
/var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/libgfortran/generated/matmul_i1.c: In function ‘matmul_i1_avx512f’: /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/libgfortran/generated/matmul_i1.c:1781:1: internal compiler error: RTL check: expected elt 0 type 'i' or 'n', have 'w' (rtx const_int) in vpternlog_redundant_operand_mask, at config/i386/i386.cc:19460 1781 | } | ^ 0x5559de26dc2d rtl_check_failed_type2(rtx_def const*, int, int, int, char const*, int, char const*) /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/rtl.cc:761 0x5559de340bfe vpternlog_redundant_operand_mask(rtx_def**) /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/config/i386/i386.cc:19460 0x5559dfec67a6 split_44 /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/config/i386/sse.md:12730 0x5559dfec67a6 split_63 /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/config/i386/sse.md:28428 0x5559deb8a682 try_split(rtx_def*, rtx_insn*, int) /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/emit-rtl.cc:3800 0x5559deb8adf2 try_split(rtx_def*, rtx_insn*, int) /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/emit-rtl.cc:3972 0x5559def69194 split_insn /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/recog.cc:3385 0x5559def70c57 split_all_insns() /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/recog.cc:3489 0x5559def70d0c execute /var/tmp/portage/sys-devel/gcc-14.0.0_pre20230806/work/gcc-14-20230806/gcc/recog.cc:4413 Use INTVAL (imm_op) instead of XINT (imm_op, 0). gcc/ChangeLog: PR target/110926 * config/i386/i386-protos.h (vpternlog_redundant_operand_mask): Adjust parameter type. * config/i386/i386.cc (vpternlog_redundant_operand_mask): Use INTVAL instead of XINT, also adjust parameter type from rtx* to rtx since the function only needs operands[4] in vpternlog pattern. (substitute_vpternlog_operands): Pass operands[4] instead of operands to vpternlog_redundant_operand_mask. * config/i386/sse.md: Ditto.
2023-08-07Improve -fopt-info-vec for basic-block vectorizationRichard Biener1-0/+8
We currently dump notes like flow_lam.f:65:72: optimized: basic block part vectorized using 32 byte vectors flow_lam.f:65:72: optimized: basic block part vectorized using 32 byte vectors flow_lam.f:65:72: optimized: basic block part vectorized using 32 byte vectors flow_lam.f:65:72: optimized: basic block part vectorized using 32 byte vectors .. repeating the same location for multiple instances because we clobber vect_location during BB vectorization. The following avoids this, improving things to flow_lam.f:15:72: optimized: basic block part vectorized using 32 byte vectors flow_lam.f:16:72: optimized: basic block part vectorized using 32 byte vectors flow_lam.f:17:72: optimized: basic block part vectorized using 32 byte vectors flow_lam.f:18:72: optimized: basic block part vectorized using 32 byte vectors ... * tree-vect-slp.cc (vect_slp_region): Save/restore vect_location around dumping code.
2023-08-07i386: Clear upper bits of XMM register for V4HFmode/V2HFmode operations ↵liuhongt3-29/+177
[PR110762] Similar like r14-2786-gade30fad6669e5, the patch is for V4HF/V2HFmode. gcc/ChangeLog: PR target/110762 * config/i386/mmx.md (<insn><mode>3): Changed from define_insn to define_expand and break into .. (<insn>v4hf3): .. this. (divv4hf3): .. this. (<insn>v2hf3): .. this. (divv2hf3): .. this. (movd_v2hf_to_sse): New define_expand. (movq_<mode>_to_sse): Extend to V4HFmode. (mmxdoublevecmode): Ditto. (V2FI_V4HF): New mode iterator. * config/i386/sse.md (*vec_concatv4sf): Extend to hanlde V8HF by using mode iterator V4SF_V8HF, renamed to .. (*vec_concat<mode>): .. this. (*vec_concatv4sf_0): Extend to handle V8HF by using mode iterator V4SF_V8HF, renamed to .. (*vec_concat<mode>_0): .. this. (*vec_concatv8hf_movss): New define_insn. (V4SF_V8HF): New mode iterator. gcc/testsuite/ChangeLog: * gcc.target/i386/pr110762-v4hf.c: New test.
2023-08-07ada: Refactor multiple returnsSheri Bernstein1-15/+15
Replace multiple returns by a single return statement with a conditional expression. This is more readable and maintainable, and also conformant with a Highly Recommended design principle of ISO 26262-6. gcc/ada/ * libgnat/s-parame__qnx.adb: Refactor multiple returns.
2023-08-07ada: Extend precondition of Interfaces.C.String.Value with LengthPiotr Trojanek1-4/+4
The existing precondition guarded against exception Dereference_Error, but not against Constraint_Error. The RM rule B.3.1(36/3) only mentions Constraint_Error for the Value function which returns char_array, but the one which returns String has the same restriction, because it is equivalent to calling the variant which returns char_array and then converted. gcc/ada/ * libgnat/i-cstrin.ads (Value): Extend preconditions; adapt comment for the package.