aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2023-10-17d: Forbid taking the address of an intrinsic with no implementationIain Buclaw6-63/+222
This code fails to link: import core.math; real function(real) fn = &sin; However, when called directly, the D intrinsic `sin()' is expanded by the front-end into the GCC built-in `__builtin_sin()'. This has been fixed to now also expand the function when a reference is taken. As there are D intrinsics and GCC built-ins that don't have a fallback implementation, raise an error if taking the address is not possible. gcc/d/ChangeLog: * d-tree.h (intrinsic_code): Update define for DEF_D_INTRINSIC. (maybe_reject_intrinsic): New prototype. * expr.cc (ExprVisitor::visit (SymOffExp *)): Call maybe_reject_intrinsic. * intrinsics.cc (intrinsic_decl): Add fallback field. (intrinsic_decls): Update define for DEF_D_INTRINSIC. (maybe_reject_intrinsic): New function. * intrinsics.def (DEF_D_LIB_BUILTIN): Update. (DEF_CTFE_BUILTIN): Update. (INTRINSIC_BSF): Declare as library builtin. (INTRINSIC_BSR): Likewise. (INTRINSIC_BT): Likewise. (INTRINSIC_BSF64): Likewise. (INTRINSIC_BSR64): Likewise. (INTRINSIC_BT64): Likewise. (INTRINSIC_POPCNT32): Likewise. (INTRINSIC_POPCNT64): Likewise. (INTRINSIC_ROL): Likewise. (INTRINSIC_ROL_TIARG): Likewise. (INTRINSIC_ROR): Likewise. (INTRINSIC_ROR_TIARG): Likewise. (INTRINSIC_ADDS): Likewise. (INTRINSIC_ADDSL): Likewise. (INTRINSIC_ADDU): Likewise. (INTRINSIC_ADDUL): Likewise. (INTRINSIC_SUBS): Likewise. (INTRINSIC_SUBSL): Likewise. (INTRINSIC_SUBU): Likewise. (INTRINSIC_SUBUL): Likewise. (INTRINSIC_MULS): Likewise. (INTRINSIC_MULSL): Likewise. (INTRINSIC_MULU): Likewise. (INTRINSIC_MULUI): Likewise. (INTRINSIC_MULUL): Likewise. (INTRINSIC_NEGS): Likewise. (INTRINSIC_NEGSL): Likewise. (INTRINSIC_TOPRECF): Likewise. (INTRINSIC_TOPREC): Likewise. (INTRINSIC_TOPRECL): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/builtins_reject.d: New test. * gdc.dg/intrinsics_reject.d: New test.
2023-10-17Daily bump.GCC Administrator5-1/+214
2023-10-16Fix minor problem in stack probingJeff Law1-1/+4
probe_stack_range has an assert to capture the possibility that that expand_binop might not construct its result in the provided target. We triggered that internally a little while ago. I'm pretty sure it was in the testsuite, so no new testcase. The fix is easy, copy the result into the proper target when needed. Bootstrapped and regression tested on x86. gcc/ * explow.cc (probe_stack_range): Handle case when expand_binop does not construct its result in the expected location.
2023-10-16diagnostics: special-case -fdiagnostics-text-art-charset=ascii for LANG=CDavid Malcolm2-3/+13
In the LWN discussion of the "ASCII" art in GCC 14 https://lwn.net/Articles/946733/#Comments there was some concern about the use of non-ASCII characters in the output. Currently -fdiagnostics-text-art-charset defaults to "emoji". To better handle older terminals by default, this patch special-cases LANG=C to use -fdiagnostics-text-art-charset=ascii. gcc/ChangeLog: * diagnostic.cc (diagnostic_initialize): When LANG=C, update default for -fdiagnostics-text-art-charset from emoji to ascii. * doc/invoke.texi (fdiagnostics-text-art-charset): Document the above. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-10-16diagnostics: fix missing initialization of context->extra_output_kindDavid Malcolm1-1/+1
gcc/ChangeLog: * diagnostic.cc (diagnostic_initialize): Ensure context->extra_output_kind is initialized. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-10-16i386: Allow -mlarge-data-threshold with -mcmodel=largeUros Bizjak4-7/+23
From: Fangrui Song <maskray@google.com> When using -mcmodel=medium, large data objects larger than the -mlarge-data-threshold threshold are placed into large data sections (.lrodata, .ldata, .lbss and some variants). GNU ld and ld.lld 17 place .l* sections into separate output sections. If small and medium code model object files are mixed, the .l* sections won't exert relocation overflow pressure on sections in object files built with -mcmodel=small. However, when using -mcmodel=large, -mlarge-data-threshold doesn't apply. This means that the .rodata/.data/.bss sections may exert relocation overflow pressure on sections in -mcmodel=small object files. This patch allows -mcmodel=large to generate .l* sections and drops an unneeded documentation restriction that the value must be the same. Link: https://groups.google.com/g/x86-64-abi/c/jnQdJeabxiU ("Large data sections for the large code model") Signed-off-by: Fangrui Song <maskray@google.com> gcc/ChangeLog: * config/i386/i386.cc (ix86_can_inline_p): Handle CM_LARGE and CM_LARGE_PIC. (x86_elf_aligned_decl_common): Ditto. (x86_output_aligned_bss): Ditto. * config/i386/i386.opt: Update doc for -mlarge-data-threshold=. * doc/invoke.texi: Update doc for -mlarge-data-threshold=. gcc/testsuite/ChangeLog: * gcc.target/i386/large-data.c: New test.
2023-10-16RISC-V: NFC: Move scalar block move expansion code into riscv-string.ccChristoph Müllner3-157/+158
This just moves a few functions out of riscv.cc into riscv-string.cc in an attempt to keep riscv.cc manageable. This was originally Christoph's code and I'm just pushing it on his behalf. Full disclosure: I built rv64gc after changing to verify everything still builds. Given it was just lifting code from one place to another, I didn't run the testsuite. gcc/ * config/riscv/riscv-protos.h (emit_block_move): Remove redundant prototype. Improve comment. * config/riscv/riscv.cc (riscv_block_move_straight): Move from riscv.cc into riscv-string.cc. (riscv_adjust_block_mem, riscv_block_move_loop): Likewise. (riscv_expand_block_move): Likewise. * config/riscv/riscv-string.cc (riscv_block_move_straight): Add moved function. (riscv_adjust_block_mem, riscv_block_move_loop): Likewise. (riscv_expand_block_move): Likewise.
2023-10-16RISC-V/testsuite: add a default march (lacking zfa) to some fp testsVineet Gupta10-10/+20
A bunch of FP tests expecting specific FP asm output fail when built with zfa because different insns are generated. And this happens because those tests don't have an explicit -march and the default used to configure gcc could end up with zfa causing the false fails. Fix that by adding the -march explicitly which doesn't have zfa. BTW it seems we have some duplication in tests for zfa and non-zfa and it would have been better if they were consolidated, but oh well. gcc/testsuite: * gcc.target/riscv/fle-ieee.c: Updates dg-options with explicit -march=rv64gc and -march=rv32gc. * gcc.target/riscv/fle-snan.c: Ditto. * gcc.target/riscv/fle.c: Ditto. * gcc.target/riscv/flef-ieee.c: Ditto. * gcc.target/riscv/flef.c: Ditto. * gcc.target/riscv/flef-snan.c: Ditto. * gcc.target/riscv/flt-ieee.c: Ditto. * gcc.target/riscv/flt-snan.c: Ditto. * gcc.target/riscv/fltf-ieee.c: Ditto. * gcc.target/riscv/fltf-snan.c: Ditto. Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
2023-10-16Implement new RTL optimizations pass: fold-mem-offsetsManolis Tsamis10-1/+974
This is a new RTL pass that tries to optimize memory offset calculations by moving them from add immediate instructions to the memory loads/stores. For example it can transform this: addi t4,sp,16 add t2,a6,t4 shl t3,t2,1 ld a2,0(t3) addi a2,1 sd a2,8(t2) into the following (one instruction less): add t2,a6,sp shl t3,t2,1 ld a2,32(t3) addi a2,1 sd a2,24(t2) Although there are places where this is done already, this pass is more powerful and can handle the more difficult cases that are currently not optimized. Also, it runs late enough and can optimize away unnecessary stack pointer calculations. gcc/ChangeLog: * Makefile.in: Add fold-mem-offsets.o. * passes.def: Schedule a new pass. * tree-pass.h (make_pass_fold_mem_offsets): Declare. * common.opt: New options. * doc/invoke.texi: Document new option. * fold-mem-offsets.cc: New file. gcc/testsuite/ChangeLog: * gcc.target/riscv/fold-mem-offsets-1.c: New test. * gcc.target/riscv/fold-mem-offsets-2.c: New test. * gcc.target/riscv/fold-mem-offsets-3.c: New test. * gcc.target/i386/pr52146.c: Adjust expected output. Signed-off-by: Manolis Tsamis <manolis.tsamis@vrull.eu>
2023-10-16d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.Iain Buclaw87-1931/+2237
D front-end changes: - Import latest fixes to mainline. D runtime changes: - Import latest fixes to mainline. Phobos changes: - Import latest fixes to mainline. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 4c18eed967. * d-diagnostic.cc (verrorReport): Update for new front-end interface. (verrorReportSupplemental): Likewise. * d-lang.cc (d_init_options): Likewise. (d_handle_option): Likewise. (d_post_options): Likewise. (d_parse_file): Likewise. * decl.cc (get_symbol_decl): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 4c18eed967. * src/MERGE: Merge upstream phobos d945686a4.
2023-10-16MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.Andrew Pinski3-20/+104
This improves the `A CMP 0 ? A : -A` set of match patterns to use bitwise_equal_p which allows an nop cast between signed and unsigned. This allows catching a few extra cases which were not being caught before. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: PR tree-optimization/101541 * match.pd (A CMP 0 ? A : -A): Improve using bitwise_equal_p. gcc/testsuite/ChangeLog: PR tree-optimization/101541 * gcc.dg/tree-ssa/phi-opt-36.c: New test. * gcc.dg/tree-ssa/phi-opt-37.c: New test.
2023-10-16[PR31531] MATCH: Improve ~a < ~b and ~a < CST, allow a nop cast inbetween ~ ↵Andrew Pinski3-4/+59
and a/b Currently we able to simplify `~a CMP ~b` to `b CMP a` but we should allow a nop conversion in between the `~` and the `a` which can show up. A similarly thing should be done for `~a CMP CST`. I had originally submitted the `~a CMP CST` case as https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585088.html; I noticed we should do the same thing for the `~a CMP ~b` case and combined it with that one here. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/31531 gcc/ChangeLog: * match.pd (~X op ~Y): Allow for an optional nop convert. (~X op C): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr31531-1.c: New test. * gcc.dg/tree-ssa/pr31531-2.c: New test.
2023-10-16c++: improve fold-expr locationJason Merrill7-54/+66
I want to distinguish between constraint && and fold-expressions there of written by the user and those implied by template parameter type-constraints; to that end, let's improve our EXPR_LOCATION for an explicit fold-expression. The fold3.C change is needed because this moves the caret from the end of the expression to the operator, which means the location of the error refers to the macro invocation rather than the macro definition; both locations are still printed, but which one is an error and which a note changes. gcc/cp/ChangeLog: * parser.cc (cp_parser_fold_expression): Track location range. * semantics.cc (finish_unary_fold_expr) (finish_left_unary_fold_expr, finish_right_unary_fold_expr) (finish_binary_fold_expr): Add location parm. * constraint.cc (finish_shorthand_constraint): Pass it. * pt.cc (convert_generic_types_to_packs): Likewise. * cp-tree.h: Adjust. gcc/testsuite/ChangeLog: * g++.dg/concepts/diagnostic3.C: Add expected column. * g++.dg/cpp1z/fold3.C: Adjust diagnostic lines.
2023-10-16c++: fix truncated diagnostic in C++23 [PR111272]Marek Polacek2-1/+30
In C++23, since P2448, a constexpr function F that calls a non-constexpr function N is OK as long as we don't actually call F in a constexpr context. So instead of giving an error in maybe_save_constexpr_fundef, we only give an error when evaluating the call. Unfortunately, as shown in this PR, the diagnostic can be truncated: z.C:10:13: note: 'constexpr Jam::Jam()' is not usable as a 'constexpr' function because: 10 | constexpr Jam() { ft(); } | ^~~ ...because what? With this patch, we say: z.C:10:13: note: 'constexpr Jam::Jam()' is not usable as a 'constexpr' function because: 10 | constexpr Jam() { ft(); } | ^~~ z.C:10:23: error: call to non-'constexpr' function 'int Jam::ft()' 10 | constexpr Jam() { ft(); } | ~~^~ z.C:8:7: note: 'int Jam::ft()' declared here 8 | int ft() { return 42; } | ^~ Like maybe_save_constexpr_fundef, explain_invalid_constexpr_fn should also check the body of a constructor, not just the mem-initializer. PR c++/111272 gcc/cp/ChangeLog: * constexpr.cc (explain_invalid_constexpr_fn): Also check the body of a constructor in C++14 and up. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/constexpr-diag1.C: New test.
2023-10-16ARC: Split asl dst,1,src into bset dst,0,src to implement 1<<x.Roger Sayle1-0/+16
This patch adds a pre-reload splitter to arc.md, to use the bset (set specific bit instruction) to implement 1<<x (i.e. left shifts of one) on ARC processors that don't have a barrel shifter. Currently, int foo(int x) { return 1 << x; } when compiled with -O2 -mcpu=em is compiled as a loop: foo: mov_s r2,1 ;3 and.f lp_count,r0, 0x1f lpnz 2f add r2,r2,r2 nop 2: # end single insn loop j_s.d [blink] mov_s r0,r2 ;4 with this patch we instead generate a single instruction: foo: bset r0,0,r0 j_s [blink] 2023-10-16 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/arc/arc.md (*ashlsi3_1): New pre-reload splitter to use bset dst,0,src to implement 1<<x on !TARGET_BARREL_SHIFTER.
2023-10-16s390: Fix expander popcountv8hi2_vxStefan Schulze Frielinghaus1-8/+8
The normal form of a CONST_INT which represents an integer of a mode with fewer bits than in HOST_WIDE_INT is sign extended. This even holds for unsigned integers. This fixes an ICE during cse1 where we bail out at rtl.h:2297 since INTVAL (x.first) == sext_hwi (INTVAL (x.first), precision) does not hold. gcc/ChangeLog: * config/s390/vector.md (popcountv8hi2_vx): Sign extend each unsigned vector element.
2023-10-16RISC-V: Use VLS modes if the NITERS is known and smaller than VLS mode elements.Juzhe-Zhong2-4/+73
void foo8 (int64_t *restrict a) { for (int i = 0; i < 16; ++i) a[i] = a[i]-16; } We use VLS modes instead of VLA modes even it is specified by dynamic LMUL. gcc/ChangeLog: * config/riscv/riscv-vector-costs.cc (costs::preferred_new_lmul_p): Use VLS modes. gcc/testsuite/ChangeLog: * gcc.dg/vect/costmodel/riscv/rvv/no-dynamic-lmul-1.c: New test.
2023-10-16use more get_range_queryJiufu Guo5-17/+6
For "get_global_range_query" SSA_NAME_RANGE_INFO can be queried. For "get_range_query", it could get more context-aware range info. And look at the implementation of "get_range_query", it returns global range if no local fun info. So, if not quering for SSA_NAME and not chaning the IL, it would be ok to use get_range_query to replace get_global_range_query. gcc/ChangeLog: * fold-const.cc (expr_not_equal_to): Replace get_global_range_query by get_range_query. * gimple-fold.cc (size_must_be_zero_p): Likewise. * gimple-range-fold.cc (fur_source::fur_source): Likewise. * gimple-ssa-warn-access.cc (check_nul_terminated_array): Likewise. * tree-dfa.cc (get_ref_base_and_extent): Likewise.
2023-10-16Support 32/64-bit vectorization for conversion between _Float16 and ↵liuhongt3-25/+262
integer/float. gcc/ChangeLog: * config/i386/mmx.md (V2FI_32): New mode iterator (movd_v2hf_to_sse): Rename to .. (movd_<mode>_to_sse): .. this. (movd_v2hf_to_sse_reg): Rename to .. (movd_<mode>_to_sse_reg): .. this. (fix<fixunssuffix>_trunc<mode><mmxintvecmodelower>2): New expander. (fix<fixunssuffix>_truncv2hfv2si2): Ditto. (float<floatunssuffix><mmxintvecmodelower><mode>2): Ditto. (float<floatunssuffix>v2siv2hf2): Ditto. (extendv2hfv2sf2): Ditto. (truncv2sfv2hf2): Ditto. * config/i386/sse.md (*vec_concatv8hf_movss): Rename to .. (*vec_concat<mode>_movss): .. this. gcc/testsuite/ChangeLog: * gcc.target/i386/part-vect-hf-convert-1.c: New test.
2023-10-16Enable vectorization for V2HF/V4HF rounding operations and sqrt.liuhongt6-11/+521
gcc/ChangeLog: * config/i386/i386-expand.cc (ix86_sse_copysign_to_positive): Handle HFmode. (ix86_expand_round_sse4): Ditto. * config/i386/i386.md (roundhf2): New expander. (lroundhf<mode>2): Ditto. (lrinthf<mode>2): Ditto. (l<rounding_insn>hf<mode>2): Ditto. * config/i386/mmx.md (sqrt<mode>2): Ditto. (btrunc<mode>2): Ditto. (nearbyint<mode>2): Ditto. (rint<mode>2): Ditto. (lrint<mode><mmxintvecmodelower>2): Ditto. (floor<mode>2): Ditto. (lfloor<mode><mmxintvecmodelower>2): Ditto. (ceil<mode>2): Ditto. (lceil<mode><mmxintvecmodelower>2): Ditto. (round<mode>2): Ditto. (lround<mode><mmxintvecmodelower>2): Ditto. * config/i386/sse.md (lrint<mode><sseintvecmodelower>2): Ditto. (lfloor<mode><sseintvecmodelower>2): Ditto. (lceil<mode><sseintvecmodelower>2): Ditto. (lround<mode><sseintvecmodelower>2): Ditto. (sse4_1_round<ssescalarmodesuffix>): Extend to V8HF. (round<mode>2): Extend to V8HF/V16HF/V32HF. gcc/testsuite/ChangeLog: * gcc.target/i386/part-vect-roundhf.c: New test. * gcc.target/i386/part-vect-sqrtph-1.c: New test.
2023-10-16Daily bump.GCC Administrator7-1/+76
2023-10-15libgomp.texi: Update "Enabling OpenMP" + OpenACC / invoke.texi: ↵Tobias Burnus2-13/+18
-fopenacc/-fopenmp update The OpenACC specification does not mention the '!$ ' sentinel for conditional compilation and the feature was removed in r11-5572-g1d6f6ac693a860 for PR fortran/98011; update libgomp.texi for this and update a leftover comment. - Additionally, some other updates are done as well. libgomp/ * libgomp.texi (Enabling OpenMP): Update for C/C++ attributes; improve wording especially for Fortran; mention -fopenmp-simd. (Enabling OpenACC): Minor cleanup; remove conditional compilation sentinel. gcc/ * doc/invoke.texi (-fopenacc, -fopenmp, -fopenmp-simd): Use @samp not @code; document more completely the supported Fortran sentinels. gcc/fortran * scanner.cc (skip_free_comments, skip_fixed_comments): Remove leftover 'OpenACC' from comments about OpenMP's conditional compilation sentinel.
2023-10-15middle-end: Improved RTL expansion of 1LL << x.Roger Sayle1-21/+26
This patch improves the initial RTL expanded for double word shifts on architectures with conditional moves, so that later passes don't need to clean-up unnecessary and/or unused instructions. Consider the general case, x << y, which is expanded well as: t1 = y & 32; t2 = 0; t3 = x_lo >> 1; t4 = y ^ ~0; t5 = t3 >> t4; tmp_hi = x_hi << y; tmp_hi |= t5; tmp_lo = x_lo << y; out_hi = t1 ? tmp_lo : tmp_hi; out_lo = t1 ? t2 : tmp_lo; which is nearly optimal, the only thing that can be improved is that using a unary NOT operation "t4 = ~y" is better than XOR with -1, on targets that support it. [Note the one_cmpl_optab expander didn't fall back to XOR when this code was originally written, but has been improved since]. Now consider the relatively common idiom of 1LL << y, which currently produces the RTL equivalent of: t1 = y & 32; t2 = 0; t3 = 1 >> 1; t4 = y ^ ~0; t5 = t3 >> t4; tmp_hi = 0 << y; tmp_hi |= t5; tmp_lo = 1 << y; out_hi = t1 ? tmp_lo : tmp_hi; out_lo = t1 ? t2 : tmp_lo; Notice here that t3 is always zero, so the assignment of t5 is a variable shift of zero, which expands to a loop on many smaller targets, a similar shift by zero in the first tmp_hi assignment (another loop), that the value of t4 is no longer required (as t3 is zero), and that the ultimate value of tmp_hi is always zero. Fortunately, for many (but perhaps not all) targets this mess gets cleaned up by later optimization passes. However, this patch avoids generating unnecessary RTL at expand time, by calling simplify_expand_binop instead of expand_binop, and avoiding generating dead or unnecessary code when intermediate values are known to be zero. For the 1LL << y test case above, we now generate: t1 = y & 32; t2 = 0; tmp_hi = 0; tmp_lo = 1 << y; out_hi = t1 ? tmp_lo : tmp_hi; out_lo = t1 ? t2 : tmp_lo; On arc-elf, for example, there are 18 RTL INSN_P instructions generated by expand before this patch, but only 12 with this patch (improving both compile-time and memory usage). 2023-10-15 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * optabs.cc (expand_subword_shift): Call simplify_expand_binop instead of expand_binop. Optimize cases (i.e. avoid generating RTL) when CARRIES or INTO_INPUT is zero. Use one_cmpl_optab (i.e. NOT) instead of xor_optab with ~0 to calculate ~OP1.
2023-10-15modula2: Add m2.etags rule to gcc/m2/Make-lang.inGaius Mulley1-0/+6
This patch adds the m2.etags rule to gcc/m2/Make-lang.in which generates etags for the .cc .c .h files within gcc/m2. gcc/m2/ChangeLog: * Make-lang.in (m2.tags): New rule. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-10-15wide-int: Fix estimation of buffer sizes for wide_int printing [PR111800]Jakub Jelinek7-33/+69
As mentioned in the PR, my estimations on needed buffer size for wide_int and especially widest_int printing were incorrect, I've used get_len () in the estimations, but that is true only for !wi::neg_p (x) values. Under the hood, we have 3 ways to print numbers. print_decs which if if ((wi.get_precision () <= HOST_BITS_PER_WIDE_INT) || (wi.get_len () == 1)) uses sprintf which always fits into WIDE_INT_PRINT_BUFFER_SIZE (positive or negative) and otherwise uses print_hex, print_decu which if if ((wi.get_precision () <= HOST_BITS_PER_WIDE_INT) || (wi.get_len () == 1 && !wi::neg_p (wi))) uses sprintf which always fits into WIDE_INT_PRINT_BUFFER_SIZE (positive only) and print_hex, which doesn't print most significant limbs which are zero and the first limb which is non-zero prints such that redundant 0 hex digits aren't printed, while all limbs below that are printed with "%016" PRIx64. For wi::neg_p (x) values, the first limb of the precision is always non-zero, so we print all the limbs for the precision. So, the current estimations are accurate if !wi::neg_p (x), or when print_decs will be used and x.get_len () == 1, otherwise we need to use estimation based on get_precision () rather than get_len (). I've introduced new inlines print_{dec{,s,u},hex}_buf_size which compute the needed buffer length in bytes and return true if WIDE_INT_PRINT_BUFFER_SIZE isn't sufficient and caller should XALLOCAVEC the buffer. 2023-10-15 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/111800 gcc/ * wide-int-print.h (print_dec_buf_size, print_decs_buf_size, print_decu_buf_size, print_hex_buf_size): New inline functions. * wide-int.cc (assert_deceq): Use print_dec_buf_size. (assert_hexeq): Use print_hex_buf_size. * wide-int-print.cc (print_decs): Use print_decs_buf_size. (print_decu): Use print_decu_buf_size. (print_hex): Use print_hex_buf_size. (pp_wide_int_large): Use print_dec_buf_size. * value-range.cc (irange_bitmask::dump): Use print_hex_buf_size. * value-range-pretty-print.cc (vrange_printer::print_irange_bitmasks): Likewise. * tree-ssa-loop-niter.cc (do_warn_aggressive_loop_optimizations): Use print_dec_buf_size. Use TYPE_SIGN macro in print_dec call argument. gcc/c-family/ * c-warn.cc (match_case_to_enum_1): Assert w.get_precision () is smaller or equal to WIDE_INT_MAX_INL_PRECISION rather than w.get_len () is smaller or equal to WIDE_INT_MAX_INL_ELTS.
2023-10-15d: Merge upstream dmd, druntime f9efc98fd7, phobos a3f22129d.Iain Buclaw167-1377/+2419
D front-end changes: - Import dmd v2.105.2. - A function with enum storage class is now deprecated. - Global variables can now be initialized with Associative Arrays. - Improvements for the C++ header generation of static variables used in a default argument context. D runtime changes: - Import druntime v2.105.2. - The `core.memory.GC' functions `GC.enable', `GC.disable', `GC.collect', and `GC.minimize' `have been marked `@safe'. Phobos changes: - Import phobos v2.105.2. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd f9efc98fd7. * dmd/VERSION: Bump version to v2.105.2. * d-builtins.cc (build_frontend_type): Update for new front-end interface. * d-diagnostic.cc (verrorReport): Don't emit tips when error gagging is turned on. * d-lang.cc (d_handle_option): Remove obsolete parameter. (d_post_options): Likewise. (d_read_ddoc_files): New function. (d_generate_ddoc_file): New function. (d_parse_file): Update for new front-end interface. * expr.cc (ExprVisitor::visit (AssocArrayLiteralExp *)): Check for new front-end lowering of static associative arrays. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime f9efc98fd7. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/internal/newaa.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos a3f22129d. * testsuite/libphobos.hash/test_hash.d: Update test. * testsuite/libphobos.phobos/phobos.exp: Add compiler flags -Wno-deprecated. * testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise. gcc/testsuite/ChangeLog: * lib/gdc-utils.exp (gdc-convert-args): Handle new compiler options.
2023-10-15combine: Fix handling of unsigned constantsStefan Schulze Frielinghaus1-2/+2
If a CONST_INT represents an integer of a mode with fewer bits than in HOST_WIDE_INT, then the integer is sign extended. For those two optimizations touched by this patch, the integers of interest have only the most significant bit set w.r.t their mode, therefore, they were sign extended. Thus in order to get the integer of interest, we have to chop off the high bits. gcc/ChangeLog: * combine.cc (simplify_compare_const): Fix handling of unsigned constants.
2023-10-15RISC-V: Fix vsingle attributeJuzhe-Zhong1-1/+1
RVVM2x2QI should be rvvm2qi instead of rvvmq1i. gcc/ChangeLog: * config/riscv/vector-iterators.md: Fix vsingle incorrect attribute for RVVM2x2QI.
2023-10-15Daily bump.GCC Administrator6-1/+130
2023-10-14Fix ICE in set_cell_span, at text-art/table.cc:148 with D front-end and ↵Iain Buclaw4-7/+66
-fanalyzer The internal error in analyzer turned out to be caused by a subtly invalid tree representation of STRING_CSTs in the D front-end, fixed by including the terminating NULL as part of the TREE_STRING_POINTER. When adding a first analyzer test for D, it flagged up another subtle mismatch in one assignment in the module support routines as well, fixed by generating the correct field type for the compiler-generated struct. PR d/111537 gcc/d/ChangeLog: * expr.cc (ExprVisitor::visit (StringExp *)): Include null terminator in STRING_CST string. * modules.cc (get_compiler_dso_type): Generate ModuleInfo** type for the minfo fields. gcc/testsuite/ChangeLog: * gdc.dg/analyzer/analyzer.exp: New test. * gdc.dg/analyzer/pr111537.d: New test.
2023-10-14d: Reduce code duplication of writing generated files.Iain Buclaw1-62/+29
Small refactoring ahead of the next merge from upstream, where a few more front-end routines will stop doing the file handling themselves. gcc/d/ChangeLog: * d-lang.cc (d_write_file): New function. (d_parse_file): Reduce code duplication.
2023-10-14Fortran: Support OpenMP's 'allocate' directive for stack varsTobias Burnus21-97/+831
gcc/fortran/ChangeLog: * gfortran.h (ext_attr_t): Add omp_allocate flag. * match.cc (gfc_free_omp_namelist): Void deleting same u2.allocator multiple times now that a sequence can use the same one. * openmp.cc (gfc_match_omp_clauses, gfc_match_omp_allocate): Use same allocator expr multiple times. (is_predefined_allocator): Make static. (gfc_resolve_omp_allocate): Update/extend restriction checks; remove sorry message. (resolve_omp_clauses): Reject corarrays in allocate/allocators directive. * parse.cc (check_omp_allocate_stmt): Permit procedure pointers here (rejected later) for less misleading diagnostic. * trans-array.cc (gfc_trans_auto_array_allocation): Propagate size for GOMP_alloc and location to which it should be added to. * trans-decl.cc (gfc_trans_deferred_vars): Handle 'omp allocate' for stack variables; sorry for static variables/common blocks. * trans-openmp.cc (gfc_trans_omp_clauses): Evaluate 'allocate' clause's allocator only once; fix adding expressions to the block. (gfc_trans_omp_single): Pass a block to gfc_trans_omp_clauses. gcc/ChangeLog: * gimplify.cc (gimplify_bind_expr): Handle Fortran's 'omp allocate' for stack variables. libgomp/ChangeLog: * libgomp.texi (OpenMP Impl. Status): Mention that Fortran now supports the allocate directive for stack variables. * testsuite/libgomp.fortran/allocate-5.f90: New test. * testsuite/libgomp.fortran/allocate-6.f90: New test. * testsuite/libgomp.fortran/allocate-7.f90: New test. * testsuite/libgomp.fortran/allocate-8.f90: New test. gcc/testsuite/ChangeLog: * c-c++-common/gomp/allocate-14.c: Fix directive name. * c-c++-common/gomp/allocate-15.c: Likewise. * c-c++-common/gomp/allocate-9.c: Fix comment typo. * gfortran.dg/gomp/allocate-4.f90: Remove sorry dg-error. * gfortran.dg/gomp/allocate-7.f90: Likewise. * gfortran.dg/gomp/allocate-10.f90: New test. * gfortran.dg/gomp/allocate-11.f90: New test. * gfortran.dg/gomp/allocate-12.f90: New test. * gfortran.dg/gomp/allocate-13.f90: New test. * gfortran.dg/gomp/allocate-14.f90: New test. * gfortran.dg/gomp/allocate-15.f90: New test. * gfortran.dg/gomp/allocate-8.f90: New test. * gfortran.dg/gomp/allocate-9.f90: New test.
2023-10-14middle-end: Allow _BitInt(65535) [PR102989]Jakub Jelinek9-62/+116
The following patch lifts further restrictions which limited _BitInt to at most 16319 bits up to 65535. The problem was mainly in INTEGER_CST representation, which had 3 unsigned char members to describe lengths in number of 64-bit limbs, which it wanted to fit into 32 bits. This patch removes the third one which was just a cache to save a few compile time cycles for wi::to_offset and enlarges the other two members to unsigned short. Furthermore, the same problem has been in some uses of trailing_wide_int* (in value-range-storage*) and value-range-storage* itself, while other uses of trailing_wide_int* have been fine (e.g. CONST_POLY_INT, where no constants will be larger than 3/5/9/11 limbs depending on target, so 255 limit is plenty). The patch turns all those length representations to be unsigned short for consistency, so value-range-storage* can handle even 16320-65535 bits BITINT_TYPE ranges. The cc1plus growth is about 16K, so not really significant for 38M .text section. Note, the reason for the new limit is unsigned int precision : 16; TYPE_PRECISION limit, if we wanted to overcome that, TYPE_PRECISION would need to use some other member for BITINT_TYPE from all the others and we could reach that way 4194239 limit (65535 * 64 - 1, again implied by INTEGER_CST and value-range-storage*). Dunno if that is worth it or if it is something we want to do for GCC 14 though. 2023-10-14 Jakub Jelinek <jakub@redhat.com> PR c/102989 gcc/ * tree-core.h (struct tree_base): Remove int_length.offset member, change type of int_length.unextended and int_length.extended from unsigned char to unsigned short. * tree.h (TREE_INT_CST_OFFSET_NUNITS): Remove. (wi::extended_tree <N>::get_len): Don't use TREE_INT_CST_OFFSET_NUNITS, instead compute it at runtime from TREE_INT_CST_EXT_NUNITS and TREE_INT_CST_NUNITS. * tree.cc (wide_int_to_tree_1): Don't assert TREE_INT_CST_OFFSET_NUNITS value. (make_int_cst): Don't initialize TREE_INT_CST_OFFSET_NUNITS. * wide-int.h (WIDE_INT_MAX_ELTS): Change from 255 to 1024. (WIDEST_INT_MAX_ELTS): Change from 510 to 2048, adjust comment. (trailing_wide_int_storage): Change m_len type from unsigned char * to unsigned short *. (trailing_wide_int_storage::trailing_wide_int_storage): Change second argument from unsigned char * to unsigned short *. (trailing_wide_ints): Change m_max_len type from unsigned char to unsigned short. Change m_len element type from struct{unsigned char len;} to unsigned short. (trailing_wide_ints <N>::operator []): Remove .len from m_len accesses. * value-range-storage.h (irange_storage::lengths_address): Change return type from const unsigned char * to const unsigned short *. (irange_storage::write_lengths_address): Change return type from unsigned char * to unsigned short *. * value-range-storage.cc (irange_storage::write_lengths_address): Likewise. (irange_storage::lengths_address): Change return type from const unsigned char * to const unsigned short *. (write_wide_int): Change len argument type from unsigned char *& to unsigned short *&. (irange_storage::set_irange): Change len variable type from unsigned char * to unsigned short *. (read_wide_int): Change len argument type from unsigned char to unsigned short. Use trailing_wide_int_storage <unsigned short> instead of trailing_wide_int_storage and trailing_wide_int <unsigned short> instead of trailing_wide_int. (irange_storage::get_irange): Change len variable type from unsigned char * to unsigned short *. (irange_storage::size): Multiply n by sizeof (unsigned short) in len_size variable initialization. (irange_storage::dump): Change len variable type from unsigned char * to unsigned short *. gcc/cp/ * module.cc (trees_out::start, trees_in::start): Remove TREE_INT_CST_OFFSET_NUNITS handling. gcc/testsuite/ * gcc.dg/bitint-38.c: Change into dg-do run test, in addition to checking the addition, division and right shift results at compile time check it also at runtime. * gcc.dg/bitint-39.c: New test.
2023-10-14RISC-V: Remove redundant iterators.Juzhe-Zhong1-110/+0
These iterators are redundant, removed and commmitted. gcc/ChangeLog: * config/riscv/vector-iterators.md: Remove redundant iterators.
2023-10-14Daily bump.GCC Administrator4-1/+224
2023-10-13Fortran: name conflict between internal procedure and derived type [PR104351]Harald Anlauf3-2/+18
gcc/fortran/ChangeLog: PR fortran/104351 * decl.cc (get_proc_name): Extend name conflict detection between internal procedure and previous declaration also to derived type. gcc/testsuite/ChangeLog: PR fortran/104351 * gfortran.dg/derived_function_interface_1.f90: Adjust pattern. * gfortran.dg/pr104351.f90: New test.
2023-10-13fortran: fix handling of options -ffpe-trap and -ffpe-summary [PR110957]Harald Anlauf2-5/+10
gcc/fortran/ChangeLog: PR fortran/110957 * invoke.texi: Update documentation to reflect '-ffpe-trap=none'. * options.cc (gfc_handle_fpe_option): Fix mixup up of error messages for options -ffpe-trap and -ffpe-summary. Accept '-ffpe-trap=none' to clear FPU traps previously set on command line.
2023-10-13Do not add partial equivalences with no uses.Andrew MacLeod1-0/+9
PR tree-optimization/111622 * value-relation.cc (equiv_oracle::add_partial_equiv): Do not register a partial equivalence if an operand has no uses.
2023-10-13OMP SIMD inbranch call vectorization for AVX512 style masksRichard Biener4-30/+175
The following teaches vectorizable_simd_clone_call to handle integer mode masks. The tricky bit is to second-guess the number of lanes represented by a single mask argument - the following uses simdlen and the number of mask arguments to calculate that, assuming ABIs have them uniform. Similar to the VOIDmode handling there's a restriction on not supporting splitting/merging of incoming vector masks to more/less SIMD call arguments. PR tree-optimization/111795 * tree-vect-stmts.cc (vectorizable_simd_clone_call): Handle integer mode mask arguments. * gcc.target/i386/vect-simd-clone-avx512-1.c: New testcase. * gcc.target/i386/vect-simd-clone-avx512-2.c: Likewise. * gcc.target/i386/vect-simd-clone-avx512-3.c: Likewise.
2023-10-13Add support for SLP vectorization of OpenMP SIMD clone callsRichard Biener4-29/+196
This adds support for SLP vectorization of OpenMP SIMD clone calls. There's a complication when vectorizing calls involving virtual operands since this is now for the first time not only leafs (loads or stores). With SLP this runs into the issue that placement of the vectorized stmts is not necessarily at one of the original scalar stmts which leads to the magic updating virtual operands in vect_finish_stmt_generation not working. So we run into the assert that updating virtual operands isn't necessary. I've papered over this similar to how we do for mismatched const/pure attribution by setting vinfo->any_known_not_updated_vssa. I've added two basic testcases with multi-lane SLP and verified that with single-lane SLP enabled the rest of the existing testcases pass. * tree-vect-slp.cc (mask_call_maps): New. (vect_get_operand_map): Handle IFN_MASK_CALL. (vect_build_slp_tree_1): Likewise. * tree-vect-stmts.cc (vectorizable_simd_clone_call): Handle SLP. * gcc.dg/vect/slp-simd-clone-1.c: New testcase. * gcc.dg/vect/slp-simd-clone-2.c: Likewise.
2023-10-13RISC-V Regression: Fix FAIL of bb-slp-68.c for RVVJuzhe-Zhong1-1/+1
Like comment said, this test failed on 64 bytes vector. Both RVV and GCN has 64 bytes vector. So it's more reasonable to use vect512. gcc/testsuite/ChangeLog: * gcc.dg/vect/bb-slp-68.c: Use vect512.
2023-10-13RISC-V: Refine run test cases of math autovecPan Li12-136/+140
For the run test cases of math autovec, we need a reference value to check if the return value is expected or not. The previous patch leverage hardcode for the reference value but we can leverage the scalar math function instead. For example ceil after autovec. ASSERT (CEIL (Vector {1.2,...}) == Vector {2.0, ...}); But we can leverage the scalar math function to avoid potential mistakes. ASSERT (CEIL (Vector {1.2,...}) == Vector {ceil (1.2), ...}); This patch remove some fflags check as it covered by check-body already. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/math-ceil-run-1.c: Use scalar func as reference instead of hardcode. * gcc.target/riscv/rvv/autovec/unop/math-ceil-run-2.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-floor-run-1.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-floor-run-2.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-1.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-2.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-rint-run-1.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-rint-run-2.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-round-run-1.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-round-run-2.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-trunc-run-1.c: Ditto. * gcc.target/riscv/rvv/autovec/unop/math-trunc-run-2.c: Ditto. Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-13RISC-V: Add test for FP llfloor auto vectorizationPan Li3-0/+114
The below FP API are supported already by sharing the same standard name, as well as the machine mode. long long llfloor (double); This patch would like to add the test cases for ensuring the correctness. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/math-llfloor-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-llfloor-run-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-llfloor-0.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-13RISC-V: Add test for FP ifloor auto vectorizationPan Li3-0/+112
The below FP API are supported already by sharing the same standard name, as well as the machine mode. int ifloor (float); This patch would like to add the test cases for ensuring the correctness. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/math-ifloor-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-ifloor-run-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-ifloor-0.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-13RISC-V: Add test for FP iceil auto vectorizationPan Li3-0/+112
The below FP API are supported already by sharing the same standard name, as well as the machine mode. int iceil (float); This patch would like to add the test cases for ensuring the correctness. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/math-iceil-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-iceil-run-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-iceil-0.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-13RISC-V: Add test for FP llceil auto vectorizationPan Li3-0/+114
The below FP API are supported already by sharing the same standard name, as well as the machine mode. long long llceil (double); This patch would like to add the test cases for ensuring the correctness. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/unop/math-llceil-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-llceil-run-0.c: New test. * gcc.target/riscv/rvv/autovec/vls/math-llceil-0.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
2023-10-13C99 testsuite readiness: Some verified test case adjustmentsFlorian Weimer7-20/+19
The updated test cases still reproduce the bugs with old compilers. gcc/testsuite/ * gcc.c-torture/compile/pc44485.c (func_21): Add missing cast. * gcc.c-torture/compile/pr106101.c: Use builtins to avoid calls to undeclared functions. Change type of yyvsp to char ** and introduce yyvsp1 to avoid type errors. * gcc.c-torture/execute/pr111331-1.c: Add missing int. * gcc.dg/pr100512.c: Unreduce test case and suppress only -Wpointer-to-int-cast. * gcc.dg/pr103003.c: Likewise. * gcc.dg/pr103451.c: Add cast to long and suppress -Wdiv-by-zero only. * gcc.dg/pr68435.c: Avoid implicit int and missing static function implementation warning.
2023-10-13C99 test suite readiness: Some unverified test case adjustmentsFlorian Weimer8-9/+20
These changes are assumed not to interfere with the test objective, but it was not possible to reproduce the historic test case failures (with or without the modification here). gcc/testsuite/ * gcc.c-torture/compile/20000105-1.c: Add missing int return type. Call __builtin_exit instead of exit. * gcc.c-torture/compile/20000105-2.c: Add missing void types. * gcc.c-torture/compile/20000211-1.c (Lstream_fputc, Lstream_write) (Lstream_flush_out, parse_doprnt_spec): Add missing function declaration. * gcc.c-torture/compile/20000224-1.c (call_critical_lisp_code): Declare. * gcc.c-torture/compile/20000314-2.c: Add missing void types. * gcc.c-torture/compile/980816-1.c (XtVaCreateManagedWidget) (XtAddCallback): Likewise. * gcc.c-torture/compile/pr49474.c: Use struct gfc_formal_arglist * instead of (implied) int type. * gcc.c-torture/execute/20001111-1.c (foo): Add cast to char *. (main): Call __builtin_abort and __builtin_exit.
2023-10-13C99 test suite readiness: Mark some C89 testsFlorian Weimer5-0/+5
Add -std=gnu89 to some tests which evidently target C89-only language features. gcc/testsuite/ * gcc.c-torture/compile/920501-11.c: Compile with -std=gnu89. * gcc.c-torture/compile/920501-23.c: Likewise. * gcc.c-torture/compile/920501-8.c: Likewise. * gcc.c-torture/compile/920701-1.c: Likewise. * gcc.c-torture/compile/930529-1.c: Likewise.
2023-10-13tree-optimization/111779 - Handle some BIT_FIELD_REFs in SRARichard Biener4-6/+83
The following handles byte-aligned, power-of-two and byte-multiple sized BIT_FIELD_REF reads in SRA. In particular this should cover BIT_FIELD_REFs created by optimize_bit_field_compare. For gcc.dg/tree-ssa/ssa-dse-26.c we now SRA the BIT_FIELD_REF appearing there leading to more DSE, fully eliding the aggregates. This results in the same false positive -Wuninitialized as the older attempt to remove the folding from optimize_bit_field_compare, fixed by initializing part of the aggregate unconditionally. PR tree-optimization/111779 gcc/ * tree-sra.cc (sra_handled_bf_read_p): New function. (build_access_from_expr_1): Handle some BIT_FIELD_REFs. (sra_modify_expr): Likewise. (make_fancy_name_1): Skip over BIT_FIELD_REF. gcc/fortran/ * trans-expr.cc (gfc_trans_assignment_1): Initialize lhs_caf_attr and rhs_caf_attr codimension flag to avoid false positive -Wuninitialized. gcc/testsuite/ * gcc.dg/tree-ssa/ssa-dse-26.c: Adjust for more DSE. * gcc.dg/vect/vect-pr111779.c: New testcase.