aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-10-07Daily bump.GCC Administrator2-1/+23
2025-10-06AVR/LibF7: Implement sincos.Georg-Johann Lay1-0/+35
libgcc/config/avr/libf7/ * libf7-common.mk (F7_ASM_PARTS): Add D_sincos. * libf7-asm.sx: (D_sincos): New module implements sincos / sincosl. gcc/testsuite/ * gcc.target/avr/sincos-1.c: New test. (cherry picked from commit e3a05e050226aaaa4e2a2e7aee1e5651212a68f6)
2025-10-06AVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.Georg-Johann Lay1-0/+116
fmin and fmax should return the non-NaN argument in the case where exactly one argument is a NaN. Moreover, IEEE double fmin and fmax can be performed without first converting the args to the internal representation and then converting back again. PR target/122177 libgcc/config/avr/libf7/ * libf7-common.mk (m_ddd): Remove: fmin, fmax. (F7_ASM_PARTS): Add: D_fminfmax. * libf7-asm.sx (D_fmanfmax): New module. * f7-wraps.h: Rebuild. gcc/testsuite/ * gcc.target/avr/fminfmax-1.c: New test. (cherry picked from commit efb3cd64fdefab88c7787b16ad33be33f4c4a2a4)
2025-10-06AVR: Speed up IEEE double comparisons.Georg-Johann Lay1-0/+149
IEEE double can be compared without first converting them to the internal representation. libgcc/config/avr/libf7/ * libf7-common.mk (g_xdd_cmp): Remove le, lt, ge, gt, ne, eq, unord. (F7_ASM_PARTS): Add D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord. * libf7-asm.sx (D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord): New modules. * f7-wraps.h: Rebuild. gcc/testsuite/ * gcc.target/avr/cmpdi-1.c: New test. (cherry picked from commit e5731a4bc50e95245cb628505142e0adff0bb79e)
2025-10-06Daily bump.GCC Administrator1-1/+1
2025-10-05Daily bump.GCC Administrator4-1/+87
2025-10-05Add testcase for PR ada/113536Eric Botcazou1-0/+18
gcc/testsuite/ PR ada/113536 * gnat.dg/reduce2.adb: New test.
2025-10-05Ada: Remove useless Makefile variableEric Botcazou1-6/+0
gcc/ada PR ada/118343 * Makefile.rtl (LLVM_BUILD): Delete.
2025-10-03RISC-V: Use correct target in expand_vec_perm [PR121780].Robin Dapp3-1/+101
This fixes a glaring mistake in yesterday's change to the expansion of vec_perm. We should of course move tmp_target into the real target and not the other way around. I wonder why my testing hasn't caught this... PR target/121742 PR target/121780 PR target/121781 gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_vec_perm): Swap target and tmp_target. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr121780.c: New test. * gcc.target/riscv/rvv/autovec/pr121781.c: New test. (cherry picked from commit e3d5e9f0c8c6f27bf59d321d5082be7b3bb39f8a)
2025-10-03RISC-V: Handle overlap in expand_vec_perm PR121742.Robin Dapp2-3/+38
In a two-source gather we unconditionally overwrite target with the first gather's result already. If op1 == target this clobbers the source operand for the second gather. This patch uses a temporary in that case. PR target/121742 gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_vec_perm): Use temporary if op1 and target overlap. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr121742.c: New test. (cherry picked from commit f957d352bd6f240829226405e9be7960071d1b9c)
2025-10-02RISC-V: Always register vector built-in functions during LTO [PR110812]Kito Cheng7-184/+198
Previously, vector built-in functions were not properly registered during the LTO pipeline, causing link failures when vector intrinsics were used in LTO builds with mixed architecture options. This patch ensures all vector built-in functions are always registered during LTO compilation. The key changes include: - Moving pragma intrinsic flag manipulation from riscv-c.cc to riscv-vector-builtins.cc for better encapsulation - Registering all vector built-in functions regardless of current ISA extensions, deferring the actual extension checking to expansion time - Adding proper support for built-in type registration during LTO This approach is safe because we already perform extension requirement checking at expansion time. The trade-off is a slight increase in bootstrap time for LTO builds due to registering more built-in functions. PR target/110812 gcc/ChangeLog: * config/riscv/riscv-c.cc (pragma_intrinsic_flags): Remove struct. (riscv_pragma_intrinsic_flags_pollute): Remove function. (riscv_pragma_intrinsic_flags_restore): Remove function. (riscv_pragma_intrinsic): Simplify to only call handle_pragma_vector. * config/riscv/riscv-vector-builtins.cc (pragma_intrinsic_flags): Move struct definition here from riscv-c.cc. (riscv_pragma_intrinsic_flags_pollute): Move and adapt from riscv-c.cc, add zvfbfmin, zvfhmin and vector_elen_bf_16 support. (riscv_pragma_intrinsic_flags_restore): Move from riscv-c.cc. (rvv_switcher::rvv_switcher): Add pollute_flags parameter to control flag manipulation. (rvv_switcher::~rvv_switcher): Restore flags conditionally. (register_builtin_types): Use rvv_switcher without polluting flags. (get_required_extensions): Remove function. (check_required_extensions): Simplify to only check type validity. (function_instance::function_returns_void_p): Move implementation from header. (function_builder::add_function): Register placeholder for LTO. (init_builtins): Simplify and handle LTO case. (reinit_builtins): Remove function. (handle_pragma_vector): Remove extension checking. * config/riscv/riscv-vector-builtins.h (function_instance::function_returns_void_p): Add declaration. (function_call_info::function_returns_void_p): Remove inline implementation. gcc/testsuite/ChangeLog: * gcc.target/riscv/lto/pr110812_0.c: New test. * gcc.target/riscv/lto/pr110812_1.c: New test. * gcc.target/riscv/lto/riscv-lto.exp: New test driver. * gcc.target/riscv/lto/riscv_vector.h: New header wrapper.
2025-10-02Daily bump.GCC Administrator1-1/+1
2025-10-01Daily bump.GCC Administrator3-1/+11
2025-09-30Ada: Fix internal error on ill-formed Reduce attribute in Ada 2022Eric Botcazou2-3/+24
This is an internal error on the new Reduce attribute of Ada 2022 when the programmer swaps its arguments(!) The change makes it so that the compiler gives an error message instead. gcc/ada/ PR ada/117517 * sem_attr.adb (Resolve_Attribute) <Attribute_Reduce>: Try to resolve the reducer first. Fix casing of error message. gcc/testsuite/ * gnat.dg/reduce1.adb: New test.
2025-09-30Daily bump.GCC Administrator1-1/+1
2025-09-29Daily bump.GCC Administrator3-1/+54
2025-09-28Fortran: fix assignment to allocatable scalar polymorphic component [PR121616]Harald Anlauf2-0/+98
PR fortran/121616 gcc/fortran/ChangeLog: * primary.cc (gfc_variable_attr): Properly set dimension attribute from a component ref. gcc/testsuite/ChangeLog: * gfortran.dg/alloc_comp_assign_17.f90: New test. (cherry picked from commit 0899b826f7196f609fc8991456eb728802061318)
2025-09-28Fortran: ICE in character(kind=4) deferred-length array reference [PR121939]Harald Anlauf2-5/+8
PR fortran/121939 gcc/fortran/ChangeLog: * trans-types.cc (gfc_init_types): Set string flag for all character types. gcc/testsuite/ChangeLog: * gfortran.dg/deferred_character_39.f90: Disable temporary workaround for character(kind=4) deferred-length bug. (cherry picked from commit 43508d358b9e53abfc3be4e28accbd4a07154dfc)
2025-09-28Fortran: fix issues with rank-2 deferred-length character arrays [PR108581]Harald Anlauf2-0/+252
PR fortran/108581 gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_expr_descriptor): Take the dynamic string length into account when deriving the dataptr offset for a deferred-length character array. gcc/testsuite/ChangeLog: * gfortran.dg/deferred_character_39.f90: New test. (cherry picked from commit 749af11149623dbf9ba026fd98bd7f31409fdaed)
2025-09-28Daily bump.GCC Administrator1-1/+1
2025-09-27Daily bump.GCC Administrator3-1/+25
2025-09-26LoongArch: Implement TARGET_CAN_INLINE_P[PR121875].Lulu Cheng8-0/+164
Because LoongArch does not implement TARGET_CAN_INLINE_P, functions with the target attribute set and those without it cannot be inlined. At the same time, setting the always_inline attribute will cause compilation failure. To solve this problem, I implemented this hook. During the implementation process, it checks the status of the target special options of the caller and callee, such as the ISA extension. PR target/121875 gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_can_inline_p): New function. (TARGET_CAN_INLINE_P): Define. gcc/testsuite/ChangeLog: * gcc.target/loongarch/can_inline_1.c: New test. * gcc.target/loongarch/can_inline_2.c: New test. * gcc.target/loongarch/can_inline_3.c: New test. * gcc.target/loongarch/can_inline_4.c: New test. * gcc.target/loongarch/can_inline_5.c: New test. * gcc.target/loongarch/can_inline_6.c: New test. * gcc.target/loongarch/pr121875.c: New test. (cherry picked from commit d6ee89a65bd98b14940245ec79814ae3d38b0121)
2025-09-26Daily bump.GCC Administrator4-1/+37
2025-09-25match.pd: Add missing type check to reduc(ctor) pattern [PR121772]Alex Coplan2-0/+6
In this PR we have a reduction of a vector constructor, where the type of the constructor is int16x8_t and the elements are int16x4_t; i.e. it is representing a concatenation of two vectors. This triggers a match.pd pattern which looks like it was written to handle reductions of vector constructors where the elements of the ctor are scalars, not vectors. There is no type check to enforce this property, which leads to the pattern replacing a reduction to scalar with an int16x4_t vector in this case, which of course is a type error, leading to an invalid GIMPLE ICE. This patch adds a type check to the pattern, only going ahead with the transformation if the element type of the ctor matches that of the reduction. gcc/ChangeLog: PR tree-optimization/121772 * match.pd: Add type check to reduc(ctor) pattern. gcc/testsuite/ChangeLog: PR tree-optimization/121772 * gcc.target/aarch64/torture/pr121772.c: New test. (cherry picked from commit a7a9b7badc0ba95b510c7e61da6439fca78e31d3)
2025-09-25c++/modules: Remove incorrect assertion [PR122015,PR122019]Nathaniel Shead1-1/+0
This assertion, despite what I said in r16-4070, is not valid: we can reach here when deduping a VAR_DECL that didn't get a LANG_SPECIFIC in the current TU. It's still correct to always use lang_cplusplus however as for anything else the decl would have been created with an appropriate LANG_SPECIFIC to start with. PR c++/122015 PR c++/122019 gcc/cp/ChangeLog: * module.cc (trees_in::install_entity): Remove incorrect assertion. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> (cherry picked from commit 4f9f1269f4e929ee471b717b47c33d2d5a3db0d3)
2025-09-25OpenMP: Unshare expr in context-selector condition [PR121922]Tobias Burnus1-1/+1
As the testcase shows, a missing unshare_expr caused that the condition was only evaluated once instead of every time when a 'declare variant' was resolved. PR middle-end/121922 gcc/ChangeLog: * omp-general.cc (omp_dynamic_cond): Use 'unshare_expr' for the user condition. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/declare-variant-1.c: New test. Co-authored-by: Sandra Loosemore <sloosemore@baylibre.com> (cherry picked from commit 97c1d2fa97afc59b02d2894b88069136145603e2)
2025-09-25Daily bump.GCC Administrator4-1/+284
2025-09-24c++: find_template_parameters and NTTPs [PR121981]Patrick Palka2-1/+21
Here the normal form of the two immediately-declared D<<placeholder>, V> constraints is the same, so we rightfully share the normal form between them. We first compute the normal form from the context of auto deduction for W in which case the placeholder has level 2 where the set of in-scope template parameters has depth 2 (a dummy level is added from normalize_placeholder_type_constraints). Naturally the atomic constraint only depends on the template parameter V of depth 1 index 0. The depth 2 of current_template_parms however means that find_template_parameters when it sees V within the atomic constraint will recurse into its TREE_TYPE, an auto of level 2, and mark the atomic constraint as also depending on the template parameter of depth 2 index 0, which is clearly wrong. Later during constraint checking for B we ICE within the satisfaction cache since we lack two levels of template arguments supposedly needed by the cached atomic constraint. I think when find_template_parameters sees an NTTP, it doesn't need to walk its TREE_TYPE because NTTP substitution is done obliviously with respect to its type -- only the corresponding NTTP argument matters, not other template arguments possibly used within its type. This is most clearly true for (unconstrained) auto NTTPs as in the testcase, but also true for other NTTPs. Doing so fixes the testcase because we no longer record any depth 2 when walking V within the atomic constraint. PR c++/121981 gcc/cp/ChangeLog: * pt.cc (any_template_parm_r) <case TEMPLATE_TYPE_PARM>: Don't walk TREE_TYPE. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-placeholder15.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com> (cherry picked from commit 396e9118849c4b918eaf3edcfa60d36e2b973019)
2025-09-24openmp: Fix up ICE in lower_omp_regimplify_operands_p [PR121977]Jakub Jelinek2-0/+19
The following testcase ICEs in functions called from lower_omp_regimplify_operands_p, because maybe_lookup_decl returns NULL for this (on the outer taskloop context) when regimplifying the taskloop pre body. If it isn't found in current context, we should look in outer ones. 2025-09-18 Jakub Jelinek <jakub@redhat.com> PR c++/121977 * omp-low.cc (lower_omp_regimplify_operands_p): If maybe_lookup_decl returns NULL, use maybe_lookup_decl_in_outer_ctx as fallback. * g++.dg/gomp/pr121977.C: New test. (cherry picked from commit b49f1dad54d3638384780c11ed17ab43f6d5d86f)
2025-09-24docs: Adjust -Wimplicit-fallthrough= documentation for C23Jakub Jelinek1-1/+1
I've noticed in -Wimplicit-fallthrough= documentation we talk about [[fallthrough]]; for C++17 but don't mention that it is also standard way to suppress the warning for C23. 2025-09-16 Jakub Jelinek <jakub@redhat.com> * doc/invoke.texi (Wimplicit-fallthrough=): Document that also C23 provides a standard way to suppress the warning with [[fallthrough]];. (cherry picked from commit 5eb86c29d29fa25f8ad81d75730a993bb03fb558)
2025-09-24testsuite: Only scan for known file extensions in lto.expJakub Jelinek1-2/+2
This is something that has bothered me for a few years but I've only found time for it now. The glob used for finding *_1.* etc. counterparts to the *_0.* tests is too broad, so if one has say next to *_1.c file also *_1.c~ or *_1.c.~1~ or *_1.c.orig or *_1.c.bak etc. files, lto.exp will report a warning and the test will fail. So, e.g. in rpm build if some backported commit in patch form adds some gcc/testsuite/*.dg/lto/ test and one uses -b option to patch, if one doesn't remove the backup files, the test will fail. Looking through all the *.dg/lto/ directories, I only see c, C, ii, f, f90 and d extensions used right now for the *_1.* files (and higher), while for the *_0.* files also m, mm and f03 extensions are used. So, the following patch only searches for those (plus for Fortran uses the extensions searched by the gfortran.dg/lto/ driver, i.e. \[fF\]{,90,95,03,08} , not just f, f90 and f03). Tested on x86_64-linux and verified I got exactly the same number of grep '^Executing.on.host.*_[1-9]\.' testsuite/*/*.log before/after this patch when doing make check RUNTESTFLAGS=lto.exp except for 2 new ones which were previously failed because I had backup files for 2 tests. 2025-09-10 Jakub Jelinek <jakub@redhat.com> * lib/lto.exp (lto-execute-1): Search for _1.* etc. files only with a list of known extensions. (cherry picked from commit 2bb8cd3609f5997b5a22925267b675808127311a)
2025-09-24bitint: Fix up lowering optimization of .*_OVERFLOW ifns [PR121828]Jakub Jelinek2-3/+75
THe lowering of .{ADD,SUB,MUL}_OVERFLOW ifns is optimized, so that we don't in the common cases uselessly don't create a large _Complex _BitInt temporary with the first (real) part being the result and second (imag) part just being a huge 0 or 1, although we still do that if it can't be done. The optimizable_arith_overflow function checks when that is possible, like whether the ifn result is used at most twice, once in REALPART_EXPR and once in IMAGPART_EXPR in the same bb, etc. For IMAGPART_EXPR it then checks if it has a single use which is a cast to some integral non-bitint type (usually bool or int etc.). The final check is whether that cast stmt appears after the REALPART_EXPR (the usual case), in that case it is optimizable, otherwise it is not (because the lowering for optimizable ifns of this kind is done at the location of the REALPART_EXPR and it tweaks the IMAGPART_EXPR cast location at that point, so otherwise it would be set after use. Now, we also have an optimization for the REALPART_EXPR lhs being used in a single stmt - store in the same bb, in that case we don't have to store the real part result in a temporary but it can go directly into memory. Except that nothing checks for the IMAGPART_EXPR cast being before or after the store in this case, so the following testcase ICEs because we have a use before a def stmt. In bar (the function handled right already before this patch) we have _6 = .SUB_OVERFLOW (y_4(D), x_5(D)); _1 = REALPART_EXPR <_6>; _2 = IMAGPART_EXPR <_6>; a = _1; _3 = (int) _2; baz (_3); before the lowering, so we can just store the limbs of the .SUB_OVERFLOW into the limbs of a variable and while doing that compute the value we eventually store into _3 instead of the former a = _1; stmt. In foo we have _5 = .SUB_OVERFLOW (y_3(D), x_4(D)); _1 = REALPART_EXPR <_5>; _2 = IMAGPART_EXPR <_5>; t_6 = (int) _2; baz (t_6); a = _1; and we can't do that because the lowering would be at the a = _1; stmt and would try to set t_6 to the overflow flag at that point. We don't need to punt completely and mark _5 as _Complex _BitInt VAR_DECL though in this case, all we need is not merge the a = _1; store with the .SUB_OVERFLOW and REALPART_EXPR/IMAGPART_EXPR lowering. So, add _1 to m_names and lower the first 3 stmts at the _1 = REALPART_EXPR <_5>; location, optimizable_arith_overflow returned non-zero and so the cast after IMAGPART_EXPR was after it and then a = _1; will copy from the temporary VAR_DECL to memory. 2025-09-10 Jakub Jelinek <jakub@redhat.com> PR middle-end/121828 * gimple-lower-bitint.cc (gimple_lower_bitint): For REALPART_EXPR consumed by store in the same bb and with REALPART_EXPR from optimizable_arith_overflow, don't add REALPART_EXPR lhs to the m_names bitmap only if the cast from IMAGPART_EXPR doesn't appear in between the REALPART_EXPR and the store. * gcc.dg/bitint-126.c: New test. (cherry picked from commit 29a8ce3b0bb117ed7f4b998462fe917f2a17f168)
2025-09-24expr: Handle RAW_DATA_CST in store_constructor [PR121831]Jakub Jelinek3-7/+162
I thought this wouldn't be necessary because RAW_DATA_CST can only appear inside of (array) CONSTRUCTORs within DECL_INITIAL of TREE_STATIC vars, so there shouldn't be a need to expand it. Except that we have an optimization when reading ARRAY_REF from such a CONSTRUCTOR which will try to expand the constructor if it either can be stored by pieces (I think that is just fine) or if it is mostly zeros (which is at least 75% of the initializer zeros). Now the second case is I think in some cases desirable (say 256MB initializer and just 20 elements out of that non-zero, so clear everything and store 20 elements must be fastest and short), but could be really bad as well (say 40GB initializer with 10GB non-zero in it, especially if it doesn't result in the original variable being optimized away). Maybe it would help if expand_constructor and store_constructor* etc. had some optional argument with addresses into the original VAR_DECL so that it could be copying larger amounts of data like larger RAW_DATA_CSTs from there instead of pushing those into new .rodata again. And another problem is that we apparently expand the initializes twice, expand_constructor in store_constructor can expand the stores one and if expand_constructor returns non-NULL, we then expand_expr the CONSTRUCTOR again. to the same location. This patch doesn't address either of those issues, just adds RAW_DATA_CST support to store_constructor for now. For the can_store_by_pieces cases it stores those by pieces using a new callback very similar to string_cst_read_str, for the rest (unfortunately) forces it into a memory and copies from there. 2025-09-10 Jakub Jelinek <jakub@redhat.com> PR middle-end/121831 * expr.cc (raw_data_cst_read_str): New function. (store_constructor) <case ARRAY_TYPE>: Handle RAW_DATA_CST. * g++.dg/lto/pr121831_0.C: New test. * g++.dg/lto/pr121831_1.C: New test. (cherry picked from commit 225d13c01d4e231bfabfda1c1c9135e36f55946a)
2025-09-24testsuite, powerpc, v2: Fix vsx-vectorize-* after alignment peeling [PR118567]Jakub Jelinek8-0/+288
On Tue, Jul 01, 2025 at 02:50:40PM -0500, Segher Boessenkool wrote: > No tests become good tests without effort. And tests that are not good > tests require constant maintenance! Here are two patches, either just the first one or both can be used and both were tested on powerpc64le-linux. The second one adds further 8 tests, which are dg-do run which #include the former tests, don't do any dump tests and just define the checking/main for those. 2025-09-05 Jakub Jelinek <jakub@redhat.com> PR testsuite/118567 * gcc.target/powerpc/vsx-vectorize-9.c: New test. * gcc.target/powerpc/vsx-vectorize-10.c: New test. * gcc.target/powerpc/vsx-vectorize-11.c: New test. * gcc.target/powerpc/vsx-vectorize-12.c: New test. * gcc.target/powerpc/vsx-vectorize-13.c: New test. * gcc.target/powerpc/vsx-vectorize-14.c: New test. * gcc.target/powerpc/vsx-vectorize-15.c: New test. * gcc.target/powerpc/vsx-vectorize-16.c: New test. (cherry picked from commit 8d8b6249d83609e56752ee51d2686b2f5fb062e6)
2025-09-24testsuite, powerpc, v2: Fix vsx-vectorize-* after alignment peeling [PR118567]Jakub Jelinek8-241/+7
On Tue, Jul 01, 2025 at 02:50:40PM -0500, Segher Boessenkool wrote: > No tests become good tests without effort. And tests that are not good > tests require constant maintenance! Here are two patches, either just the first one or both can be used and both were tested on powerpc64le-linux. The first one removes all the checking etc. stuff from the testcases, as they are just dg-do compile, for the vectorize dump checks all we care about are the vectorized loops they want to test. 2025-09-05 Jakub Jelinek <jakub@redhat.com> PR testsuite/118567 * gcc.target/powerpc/vsx-vectorize-1.c: Remove includes, checking part of main1 and main. * gcc.target/powerpc/vsx-vectorize-2.c: Remove includes, replace bar definition with declaration, remove main. * gcc.target/powerpc/vsx-vectorize-3.c: Likewise. * gcc.target/powerpc/vsx-vectorize-4.c: Likewise. * gcc.target/powerpc/vsx-vectorize-5.c: Likewise. * gcc.target/powerpc/vsx-vectorize-6.c: Likewise. * gcc.target/powerpc/vsx-vectorize-7.c: Likewise. * gcc.target/powerpc/vsx-vectorize-8.c: Likewise. (cherry picked from commit 193b28649933685f4dd3824c01aee4f843cc66b5)
2025-09-24omp-expand: Initialize fd->loop.n2 if needed for the zero iter case [PR121453]Jakub Jelinek2-0/+34
When expand_omp_for_init_counts is called from expand_omp_for_generic, zero_iter1_bb is NULL and the code always creates a new bb in which it clears fd->loop.n2 var (if it is a var), because it can dominate code with lastprivate guards that use the var. When called from other places, zero_iter1_bb is non-NULL and so we don't insert the clearing (and can't, because the same bb is used also for the non-zero iterations exit and in that case we need to preserve the iteration count). Clearing is also not necessary when e.g. outermost collapsed loop has constant non-zero number of iterations, in that case we initialize the var to something already earlier. The following patch makes sure to clear it if it hasn't been initialized yet before the first check for zero iterations. 2025-08-26 Jakub Jelinek <jakub@redhat.com> PR middle-end/121453 * omp-expand.cc (expand_omp_for_init_counts): Clear fd->loop.n2 before first zero count check if zero_iter1_bb is non-NULL upon entry and fd->loop.n2 has not been written yet. * gcc.dg/gomp/pr121453.c: New test. (cherry picked from commit 948f20cc520e50968f8759b173096358dcbba3de)
2025-09-24c++: Fix up build_cplus_array_type [PR121524]Jakub Jelinek2-1/+14
The following testcase is miscompiled since my r15-3046 change to properly apply std attributes after closing ] for arrays to the array type. Array type is not a class type, so when cplus_decl_attribute is called on the ARRAY_TYPE, it doesn't do ATTR_FLAG_TYPE_IN_PLACE. Though, for alignas/gnu::aligned/deprecated/gnu::unavailable/gnu::unused attributes the handlers of those attributes for non-ATTR_FLAG_TYPE_IN_PLACE on types call build_variant_type_copy and modify some flags on the new variant type. They also usually don't clear *no_add_attrs, so the caller then checks if the attributes are present on the new type and if not, calls build_type_attribute_variant. On the following testcase, it results in the B::foo type to be properly 32 byte aligned. The problem happens later when we build_cplus_array_type for C::a. elt_type is T (typedef, or using works likewise), we get as m main variant type with unsigned int element type but because elt_type is different, build_cplus_array_type searches the TYPE_NEXT_VARIANT chain to find if there isn't already a useful ARRAY_TYPE to reuse. It checks for NULL TYPE_NAME, NULL TYPE_ATTRIBUTES and the right TREE_TYPE. Unfortunately this is not good enough, build_variant_type_copy above created a variant type on which it modified TYPE_USER_ALIGN and TYPE_ALIGN, but TYPE_ATTRIBUTES is still NULL, only the build_type_attribute_variant call later adds attributes. The problem is that the intermediate type is found in the TYPE_NEXT_VARIANT chain and reused. The following patch adds conditions to prevent problems with the affected attributes (except gnu::unused, I think whether TREE_USED is set or not shouldn't prevent sharing). In particular, if TYPE_USER_ALIGN is not set on the variant, it wasn't user realigned, if it is set, it verifies it has it set because the elt_type has been user aligned and TYPE_ALIGN is the expected one. For deprecated it punts on the flag being set and for gnu::unavailable as well. 2025-08-14 Jakub Jelinek <jakub@redhat.com> PR c++/121524 * tree.cc (build_cplus_array_type): Don't reuse variant type if it has TREE_DEPRECATED or TREE_UNAVAILABLE flags set or, unless elt_type has TYPE_USER_ALIGN set and TYPE_ALIGN is TYPE_ALIGN of elt_type, TYPE_USER_ALIGN is not set. * g++.dg/cpp0x/gen-attrs-89.C: New test. (cherry picked from commit b125eee2d8526538476834773fb8216035d08598)
2025-09-24tree-optimization/122016 - PRE insertion breaks abnormal coalescingRichard Biener2-0/+33
When PRE asks VN to simplify a NARY but not insert, that bypasses the abnormal guard in maybe_push_res_to_seq and we blindly accept new uses of abnormals. The following fixes this. PR tree-optimization/122016 * tree-ssa-sccvn.cc (vn_nary_simplify): Do not use the simplified expression when it references abnormals. * gcc.dg/torture/pr122016.c: New testcase. (cherry picked from commit 52b53cfb5392257536fce8dd22ea60412ceaee7d)
2025-09-24Deal with prior EH/abormal cleanup when fixing up noreturn callsRichard Biener2-0/+22
When a dead EH or abnormal edge makes a call queued for noreturn fixup unreachable, just skip processing it. PR tree-optimization/121870 * tree-ssa-propagate.cc (substitute_and_fold_engine::substitute_and_fold): Skip removed stmts from noreturn fixup. * g++.dg/torture/pr121870.C: New testcase. (cherry picked from commit 5c4f1313e753aeb6920a48c62c7c99ad36e1adae)
2025-09-24tree-optimization/121844 - IVOPTs and asm goto in latchRichard Biener2-6/+23
When there's an asm goto in the latch of a loop we may not use IP_END IVs since instantiating those would (need to) split the latch edge which in turn invalidates IP_NORMAL position handling. This is a revision of the PR107997 fix. PR tree-optimization/107997 PR tree-optimization/121844 * tree-ssa-loop-ivopts.cc (allow_ip_end_pos_p): Do not allow IP_END for latches ending with a control stmt. (create_new_iv): Do not split the latch edge, instead assert that's not necessary. * gcc.dg/torture/pr121844.c: New testcase. (cherry picked from commit 00cd34b1046076a3272f8e8e85c97dc8f4d2ea44)
2025-09-24tree-optimization/121659 - bogus swap of reduction operandsRichard Biener2-3/+19
The following addresses a bogus swapping of SLP operands of a reduction operation which gets STMT_VINFO_REDUC_IDX out of sync with the SLP operand order. In fact the most obvious mistake is that we simply swap operands even on the first stmt even when there's no difference in the comparison operators (for == and != at least). But there are more latent issues that I noticed and fixed up in the process. PR tree-optimization/121659 * tree-vect-slp.cc (vect_build_slp_tree_1): Do not allow matching up comparison operators by swapping if that would disturb STMT_VINFO_REDUC_IDX. Make sure to only actually mark operands for swapping when there was a mismatch and we're not processing the first stmt. * gcc.dg/vect/pr121659.c: New testcase. (cherry picked from commit 68e692eed9e8e8c47d83586ee08f40c27fa3a78d)
2025-09-24tree-optimization/121527 - wrong SRA with aggregate copyRichard Biener1-14/+6
SRA handles outermost VIEW_CONVERT_EXPRs but it wrongly ignores those when building an access which leads to the wrong size used when the VIEW_CONVERT_EXPR does not have the same size as its operand which is valid GENERIC and is used by Ada upcasting. PR tree-optimization/121527 * tree-sra.cc (build_access_from_expr_1): Do not strip an outer VIEW_CONVERT_EXPR as it's relevant for the size of the access. (get_access_for_expr): Likewise. (cherry picked from commit 1d0a0173cd3e48f1c7c7e98893d440527fc198d0)
2025-09-24tree-optimization/121370 - avoid UB in building a CHRECRichard Biener2-0/+36
When there is obvious UB involved in the process of re-associating a series of IV increments to build up a CHREC, fail. This catches a few degenerate cases where SCEV introduces UB with its inherent re-associating of IV increments. PR tree-optimization/121370 * tree-scalar-evolution.cc (scev_dfs::add_to_evolution_1): Avoid UB integer overflow in accumulating CHREC_RIGHT. * gcc.dg/torture/pr121370.c: New testcase. (cherry picked from commit afafae097232e700bb7a74a453a048b83ebefccd)
2025-09-24c++/modules: Fix language linkage handling [PR122019]Nathaniel Shead3-14/+69
The ICE in the linked PR is caused because when current_lang_name is lang_name_c, set_decl_linkage calls decl_linkage on the retrofitted declaration. This is problematic because at this point we haven't finished streaming the declaration, and so we crash when attempting to access these missing bits (such as the type). The only declarations we can reach here will be things like types that don't get a language linkage anyway, so it seems reasonable to just hardcode a C++ language linkage here to work around the issue. An alternative fix would be to override current_lang_name in lazy_load_binding instead, but this is potentially confusing if we ever deliberately implement `extern "C" import "header_unit.hpp";` to override the language linkage of imported declarations, so I went with this approach instead. (Though it seems we never will do this.) While testing this I found that we don't currently complain about mismatching language linkages for variables, and module_may_redeclare doesn't cope well with implementation units, so this patch also fixes those issues. PR c++/122019 gcc/cp/ChangeLog: * module.cc (trees_in::install_entity): Don't be affected by global language linkage state. (trees_in::is_matching_decl): Check mismatching language linkage for variables too. (module_may_redeclare): Report the correct module name for partitions and implementation units. gcc/testsuite/ChangeLog: * g++.dg/modules/lang-4_a.C: New test. * g++.dg/modules/lang-4_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com> (cherry picked from commit fe2f86a960435a7c8c4e5134a0dfc64dd6062157)
2025-09-24Daily bump.GCC Administrator4-1/+38
2025-09-23Fortran: Use associated TBP subroutine not found [PR89092]Paul Thomas2-1/+50
2025-08-13 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/89092 * resolve.cc (was_declared): Add subroutine attribute. gcc/testsuite/ PR fortran/89092 * gfortran.dg/pr89092.f90: New test. (cherry picked from commit e6f4543f63366433493b3870845b555fd00be7e6)
2025-09-23c++: Fix canonical type for lambda pack captures [PR122015]Nathaniel Shead6-10/+46
comp_template_parms_position uses whether a TEMPLATE_TYPE_PARM is a pack to determine equivalency. This in turn affects whether canonical_type_parameter finds a pre-existing auto type as equivalent. When generating the 'auto...' type for a lambda pack capture, we only mark it as a pack after generating the node (and calculating its canonical); this means that later when comparing a version streamed in from a module we think that two equivalent types have different TYPE_CANONICAL, because the latter already had TEMPLATE_PARM_PARAMETER_PACK set before calculating its canonical. This patch fixes this by using a new 'make_auto_pack' function to ensure that packness is set before the canonical is looked up. PR c++/122015 gcc/cp/ChangeLog: * cp-tree.h (make_auto_pack): Declare. * lambda.cc (lambda_capture_field_type): Use make_auto_pack to ensure TYPE_CANONICAL is set correctly. * pt.cc (make_auto_pack): New function. gcc/testsuite/ChangeLog: * g++.dg/modules/lambda-11.h: New test. * g++.dg/modules/lambda-11_a.H: New test. * g++.dg/modules/lambda-11_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Patrick Palka <ppalka@redhat.com> (cherry picked from commit cc79849cc883146964f0001f33c8b7eb576825c4)
2025-09-23Daily bump.GCC Administrator2-1/+8
2025-09-22Ada: Fix internal error on use clause present in generic formal partEric Botcazou2-4/+12
This is a regression present on the mainline and 15 branch: the compiler aborts on a use clause present in the formal part of a generic unit because of an oversight in the new inference code for generic actual parameters. The fix also adds a missing test to Analyze_Dimension_Array_Aggregate. gcc/ada/ PR ada/121968 * sem_ch12.adb (Associations.Find_Assoc): Add guard for clauses. * sem_dim.adb (Analyze_Dimension_Array_Aggregate): Add test for N_Iterated_Component_Association nodes.
2025-09-22Daily bump.GCC Administrator1-1/+1