[gcc r15-7265] RISC-V: Refactor SAT_* operand rtx extend to reg help func [NFC]
https://gcc.gnu.org/g:7ab7829aef6b02d4022650566b2806af986be0cb commit r15-7265-g7ab7829aef6b02d4022650566b2806af986be0cb Author: Pan Li Date: Mon Jan 27 11:01:08 2025 +0800 RISC-V: Refactor SAT_* operand rtx extend to reg help func [NFC] This patch would like to refactor the helper function of the SAT_* scalar. The helper function will convert the define_pattern ops to the xmode reg for the underlying code-gen. This patch add new parameter for ZERO_EXTEND or SIGN_EXTEND if the input is const_int or the mode is non-Xmode. The below test suites are passed for this patch. * The rv64gcv fully regression test. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_gen_zero_extend_rtx): Rename from ... (riscv_extend_to_xmode_reg): Rename to and add rtx_code for zero/sign extend if non-Xmode. (riscv_expand_usadd): Leverage the renamed function with ZERO_EXTEND. (riscv_expand_ussub): Ditto. Signed-off-by: Pan Li Diff: --- gcc/config/riscv/riscv.cc | 78 +-- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index dd50fe4eddfb..5ee53d01f51f 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -12644,14 +12644,27 @@ riscv_get_raw_result_mode (int regno) /* Generate a REG rtx of Xmode from the given rtx and mode. The rtx x can be REG (QI/HI/SI/DI) or const_int. The machine_mode mode is the original mode from define pattern. + The rtx_code can be ZERO_EXTEND or SIGN_EXTEND. - If rtx is REG and Xmode, the RTX x will be returned directly. + If rtx is REG: - If rtx is REG and non-Xmode, the zero extended to new REG of Xmode will be - returned. + 1. If rtx Xmode, the RTX x will be returned directly. + 2. If rtx non-Xmode, the value extended into a new REG of Xmode will be + returned. - If rtx is const_int, a new REG rtx will be created to hold the value of - const_int and then returned. + The scalar ALU like add don't support non-Xmode like QI/HI. Then the + gen_lowpart will have problem here. For example, when we would like + to add -1 (0xff if QImode) and 2 (0x2 if QImode). The 0xff and 0x2 will + be loaded to register for adding. Aka: + + 0xff + 0x2 = 0x101 instead of -1 + 2 = 1. + + Thus we need to sign extend 0xff to 0x if Xmode is DImode + for correctness. Similar the unsigned also need zero extend. + + If rtx is const_int: + + 1. A new REG rtx will be created to hold the value of const_int. According to the gccint doc, the constants generated for modes with fewer bits than in HOST_WIDE_INT must be sign extended to full width. Thus there @@ -12669,34 +12682,41 @@ riscv_get_raw_result_mode (int regno) the REG rtx of Xmode, instead of taking care of these in expand func. */ static rtx -riscv_gen_zero_extend_rtx (rtx x, machine_mode mode) +riscv_extend_to_xmode_reg (rtx x, machine_mode mode, enum rtx_code rcode) { + gcc_assert (rcode == ZERO_EXTEND || rcode == SIGN_EXTEND); + rtx xmode_reg = gen_reg_rtx (Xmode); - if (!CONST_INT_P (x)) + if (CONST_INT_P (x)) { if (mode == Xmode) - return x; - - riscv_emit_unary (ZERO_EXTEND, xmode_reg, x); - return xmode_reg; -} - - if (mode == Xmode) -emit_move_insn (xmode_reg, x); - else -{ - /* Combine deliberately does not simplify extensions of constants -(long story). So try to generate the zero extended constant -efficiently. + emit_move_insn (xmode_reg, x); + else if (rcode == ZERO_EXTEND) + { + /* Combine deliberately does not simplify extensions of constants +(long story). So try to generate the zero extended constant +efficiently. -First extract the constant and mask off all the bits not in MODE. */ - HOST_WIDE_INT val = INTVAL (x); - val &= GET_MODE_MASK (mode); +First extract the constant and mask off all the bits not in +MODE. */ + HOST_WIDE_INT val = INTVAL (x); + val &= GET_MODE_MASK (mode); - /* X may need synthesis, so do not blindly copy it. */ - xmode_reg = force_reg (Xmode, gen_int_mode (val, Xmode)); + /* X may need synthesis, so do not blindly copy it. */ + xmode_reg = force_reg (Xmode, gen_int_mode (val, Xmode)); + } + else /* SIGN_EXTEND. */ + { + rtx x_reg = gen_reg_rtx (mode); + emit_move_insn (x_reg, x); + riscv_emit_unary (rcode, xmode_reg, x_reg); + } } + else if (mode == Xmode) +return x; + else +riscv_emit_unary (rcode, xmode_reg, x); return xmode_reg; } @@ -12717,8 +12737,8 @@ riscv_expand_usadd (rtx dest, rtx x, rtx y) machine_mode mode = GET_MODE (dest); rtx xmode_sum = gen_reg_rtx (Xmode); rtx xmode_lt = gen_re
[gcc r15-7266] RISC-V: Fix incorrect code gen for scalar signed SAT_ADD [PR117688]
https://gcc.gnu.org/g:81aa9488321dea5ed1d55d0dfb1a72f362a1a24f commit r15-7266-g81aa9488321dea5ed1d55d0dfb1a72f362a1a24f Author: Pan Li Date: Thu Jan 23 12:08:17 2025 +0800 RISC-V: Fix incorrect code gen for scalar signed SAT_ADD [PR117688] This patch would like to fix the wroing code generation for the scalar signed SAT_ADD. The input can be QI/HI/SI/DI while the alu like sub can only work on Xmode. Unfortunately we don't have sub/add for non-Xmode like QImode in scalar, thus we need to sign extend to Xmode to ensure we have the correct value before ALU like add. The gen_lowpart will generate something like lbu which has all zero for highest bits. For example, when 0xff(-1 for QImode) plus 0x2(1 for QImode), we actually want to -1 + 2 = 1, but if there is no sign extend like lbu, we will get 0xff + 2 = 0x101 which is incorrect. Thus, we have to sign extend 0xff(Qmode) to 0x(assume XImode is DImode) before plus in Xmode. The below test suites are passed for this patch. * The rv64gcv fully regression test. PR target/117688 gcc/ChangeLog: * config/riscv/riscv.cc (riscv_expand_ssadd): Leverage the helper riscv_extend_to_xmode_reg with SIGN_EXTEND. gcc/testsuite/ChangeLog: * gcc.target/riscv/pr117688-add-run-1-s16.c: New test. * gcc.target/riscv/pr117688-add-run-1-s32.c: New test. * gcc.target/riscv/pr117688-add-run-1-s64.c: New test. * gcc.target/riscv/pr117688-add-run-1-s8.c: New test. * gcc.target/riscv/pr117688.h: New test. Signed-off-by: Pan Li Diff: --- gcc/config/riscv/riscv.cc | 4 ++-- .../gcc.target/riscv/pr117688-add-run-1-s16.c | 6 + .../gcc.target/riscv/pr117688-add-run-1-s32.c | 6 + .../gcc.target/riscv/pr117688-add-run-1-s64.c | 6 + .../gcc.target/riscv/pr117688-add-run-1-s8.c | 6 + gcc/testsuite/gcc.target/riscv/pr117688.h | 27 ++ 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 5ee53d01f51f..8ea31846e879 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -12816,8 +12816,8 @@ riscv_expand_ssadd (rtx dest, rtx x, rtx y) machine_mode mode = GET_MODE (dest); unsigned bitsize = GET_MODE_BITSIZE (mode).to_constant (); rtx shift_bits = GEN_INT (bitsize - 1); - rtx xmode_x = gen_lowpart (Xmode, x); - rtx xmode_y = gen_lowpart (Xmode, y); + rtx xmode_x = riscv_extend_to_xmode_reg (x, mode, SIGN_EXTEND); + rtx xmode_y = riscv_extend_to_xmode_reg (y, mode, SIGN_EXTEND); rtx xmode_sum = gen_reg_rtx (Xmode); rtx xmode_dest = gen_reg_rtx (Xmode); rtx xmode_xor_0 = gen_reg_rtx (Xmode); diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s16.c b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s16.c new file mode 100644 index ..21ec107cbf10 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s16.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_ADD_RUN(int16_t, INT16_MIN, INT16_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s32.c b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s32.c new file mode 100644 index ..1f197d1280b7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s32.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_ADD_RUN(int32_t, INT32_MIN, INT32_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s64.c b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s64.c new file mode 100644 index ..4903bc854d34 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s64.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_ADD_RUN(int64_t, INT64_MIN, INT64_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s8.c new file mode 100644 index ..a9f2fe7f1920 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-add-run-1-s8.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_ADD_RUN(int8_t, INT8_MIN, INT8_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688.h b/gcc/testsuite/gcc.target/riscv/pr117688.h new file mode 100644 index ..1013a8a80128 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688.h @@ -0,0 +1,27 @@ +#ifndef HAVE_DEFINED_PR117688_H +#define HAVE_DEFINED_PR117688_H + +#include + +#define DEFINE_SIGNE
[gcc r15-7268] RISC-V: Fix incorrect code gen for scalar signed SAT_TRUNC [PR117688]
https://gcc.gnu.org/g:5a48079c15fda4863b02eb253e473c57a5105528 commit r15-7268-g5a48079c15fda4863b02eb253e473c57a5105528 Author: Pan Li Date: Thu Jan 23 14:28:39 2025 +0800 RISC-V: Fix incorrect code gen for scalar signed SAT_TRUNC [PR117688] This patch would like to fix the wroing code generation for the scalar signed SAT_TRUNC. The input can be QI/HI/SI/DI while the alu like sub can only work on Xmode. Unfortunately we don't have sub/add for non-Xmode like QImode in scalar, thus we need to sign extend to Xmode to ensure we have the correct value before ALU like add. The gen_lowpart will generate something like lbu which has all zero for highest bits. For example, when 0xff7f(-129 for HImode) trunc to QImode, we actually want compare -129 to -128, but if there is no sign extend like lbu, we will compare 0xff7f to 0xff80(assum Xmode is DImode). Thus, we have to sign extend 0xff(Qmode) to 0xff7f(assume Xmode is DImode) before compare in Xmode. The below test suites are passed for this patch. * The rv64gcv fully regression test. PR target/117688 gcc/ChangeLog: * config/riscv/riscv.cc (riscv_expand_sstrunc): Leverage the helper riscv_extend_to_xmode_reg with SIGN_EXTEND. gcc/testsuite/ChangeLog: * gcc.target/riscv/pr117688.h: Add test helper macros. * gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c: New test. * gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c: New test. * gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c: New test. * gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c: New test. * gcc.target/riscv/pr117688-trunc-run-1-s64-to-s32.c: New test. * gcc.target/riscv/pr117688-trunc-run-1-s64-to-s8.c: New test. Signed-off-by: Pan Li Diff: --- gcc/config/riscv/riscv.cc | 2 +- .../riscv/pr117688-trunc-run-1-s16-to-s8.c | 6 ++ .../riscv/pr117688-trunc-run-1-s32-to-s16.c| 6 ++ .../riscv/pr117688-trunc-run-1-s32-to-s8.c | 6 ++ .../riscv/pr117688-trunc-run-1-s64-to-s16.c| 6 ++ .../riscv/pr117688-trunc-run-1-s64-to-s32.c| 6 ++ .../riscv/pr117688-trunc-run-1-s64-to-s8.c | 6 ++ gcc/testsuite/gcc.target/riscv/pr117688.h | 22 ++ 8 files changed, 59 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 3b042e2817b8..439cc12f93d5 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -13031,7 +13031,7 @@ riscv_expand_sstrunc (rtx dest, rtx src) rtx xmode_narrow_min = gen_reg_rtx (Xmode); rtx xmode_lt = gen_reg_rtx (Xmode); rtx xmode_gt = gen_reg_rtx (Xmode); - rtx xmode_src = gen_lowpart (Xmode, src); + rtx xmode_src = riscv_extend_to_xmode_reg (src, GET_MODE (src), SIGN_EXTEND); rtx xmode_dest = gen_reg_rtx (Xmode); rtx xmode_mask = gen_reg_rtx (Xmode); rtx xmode_sat = gen_reg_rtx (Xmode); diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c new file mode 100644 index ..df84615a25f9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s16-to-s8.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_TRUNC_RUN(int16_t, int8_t, INT8_MIN, INT8_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c new file mode 100644 index ..1b0f860eb55e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s16.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_TRUNC_RUN(int32_t, int16_t, INT16_MIN, INT16_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c new file mode 100644 index ..e412a29df36a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s32-to-s8.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_TRUNC_RUN(int32_t, int8_t, INT8_MIN, INT8_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c new file mode 100644 index ..234d33b18952 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-trunc-run-1-s64-to-s16.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_
[gcc r14-11258] c++: re-enable NSDMI CONSTRUCTOR folding [PR118355]
https://gcc.gnu.org/g:8774d5076d0a30c0809dd96f3fdbec8f867eeac5 commit r14-11258-g8774d5076d0a30c0809dd96f3fdbec8f867eeac5 Author: Marek Polacek Date: Mon Jan 13 15:09:14 2025 -0500 c++: re-enable NSDMI CONSTRUCTOR folding [PR118355] In c++/102990 we had a problem where massage_init_elt got {}, digest_nsdmi_init turned that {} into { .value = (int) 1.0e+0 }, and we crashed in the call to fold_non_dependent_init because a FIX_TRUNC_EXPR/FLOAT_EXPR got into tsubst*. So we avoided calling fold_non_dependent_init for a CONSTRUCTOR. But that broke the following test, where we no longer fold the CONST_DECL in { .type = ZERO } to { .type = 0 } and then process_init_constructor_array does: if (next != error_mark_node && (initializer_constant_valid_p (next, TREE_TYPE (next)) != null_pointer_node)) { /* Use VEC_INIT_EXPR for non-constant initialization of trailing elements with no explicit initializers. */ picflags |= PICFLAG_VEC_INIT; because { .type = ZERO } isn't initializer_constant_valid_p. Then we create a VEC_INIT_EXPR and say we can't convert the argument. So we have to fold the elements of the CONSTRUCTOR. We just can't instantiate the elements in a template. This also fixes c++/118047. PR c++/118047 PR c++/118355 gcc/cp/ChangeLog: * typeck2.cc (massage_init_elt): Call fold_non_dependent_init unless for a CONSTRUCTOR in a template. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/nsdmi-list10.C: New test. * g++.dg/cpp0x/nsdmi-list9.C: New test. Reviewed-by: Jason Merrill (cherry picked from commit e939005c496dfd4058fa57b6860bfadcabe4a111) Diff: --- gcc/cp/typeck2.cc | 8 +++ gcc/testsuite/g++.dg/cpp0x/nsdmi-list10.C | 35 +++ gcc/testsuite/g++.dg/cpp0x/nsdmi-list9.C | 34 ++ 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc index b04ec559aa05..e32a4c638c59 100644 --- a/gcc/cp/typeck2.cc +++ b/gcc/cp/typeck2.cc @@ -1537,10 +1537,10 @@ massage_init_elt (tree type, tree init, int nested, int flags, new_flags |= LOOKUP_AGGREGATE_PAREN_INIT; init = digest_init_r (type, init, nested ? 2 : 1, new_flags, complain); /* When we defer constant folding within a statement, we may want to - defer this folding as well. Don't call this on CONSTRUCTORs because - their elements have already been folded, and we must avoid folding - the result of get_nsdmi. */ - if (TREE_CODE (init) != CONSTRUCTOR) + defer this folding as well. Don't call this on CONSTRUCTORs in + a template because their elements have already been folded, and + we must avoid folding the result of get_nsdmi. */ + if (!(processing_template_decl && TREE_CODE (init) == CONSTRUCTOR)) { tree t = fold_non_dependent_init (init, complain); if (TREE_CONSTANT (t)) diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list10.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list10.C new file mode 100644 index ..36b74749cbf6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list10.C @@ -0,0 +1,35 @@ +// PR c++/118047 +// { dg-do compile { target c++11 } } + +typedef decltype(sizeof(char)) size_t; + +namespace std { +template +struct initializer_list { + const T *_M_array; + size_t _M_len; + constexpr size_t size() const { return _M_len; } +}; +} + +enum E { +One +}; + +struct A { +E e = One; +}; + +struct B { +A as[1] {}; +}; + +struct V +{ + constexpr V(const std::initializer_list &a) : size(a.size()){} + int size; +}; + +constexpr V a{{}}; + +static_assert(a.size == 1, ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list9.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list9.C new file mode 100644 index ..ae69ba0810dc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list9.C @@ -0,0 +1,34 @@ +// PR c++/118355 +// { dg-do compile { target c++11 } } + +enum MY_ENUM +{ + ZERO, +}; + +struct FOO +{ + MY_ENUM type = ZERO; +}; + +struct ARR +{ + FOO array[1] = {}; +}; + +template +struct ARR2 +{ + FOO array[1] = {}; +}; + +void +g () +{ + + ARR arr; + arr = {}; + + ARR2 arr2; + arr2 = {}; +}
[gcc r14-11259] libstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413]
https://gcc.gnu.org/g:f0420cc224db64efe87cbe2f45d4d7ba8deb9eb0 commit r14-11259-gf0420cc224db64efe87cbe2f45d4d7ba8deb9eb0 Author: Patrick Palka Date: Wed Jan 29 10:02:28 2025 -0500 libstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413] The range adaptor perfect forwarding simplification mechanism is currently only enabled for trivially copyable bound arguments, to prevent undesirable copies of complex objects. But "trivially copyable" is the wrong property to check for here, since a move-only type with a trivial move constructor is considered trivially copyable, and after P2492R2 we can't assume copy constructibility of the bound arguments. This patch makes the mechanism more specifically check for trivial copy constructibility instead so that it's properly disabled for move-only bound arguments. PR libstdc++/118413 libstdc++-v3/ChangeLog: * include/std/ranges (views::__adaptor::_Partial): Adjust constraints on the "simple" partial specializations to require is_trivially_copy_constructible_v instead of is_trivially_copyable_v. * testsuite/std/ranges/adaptors/adjacent_transform/1.cc (test04): Extend P2494R2 test. * testsuite/std/ranges/adaptors/transform.cc (test09): Likewise. Reviewed-by: Jonathan Wakely (cherry picked from commit 09d1cbee10b8c51aed48f047f30717f622d6f811) Diff: --- libstdc++-v3/include/std/ranges| 4 ++-- libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc | 1 + libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc| 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index eba539176848..a966699479bb 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -1122,7 +1122,7 @@ namespace views::__adaptor // which makes overload resolution failure diagnostics more concise. template requires __adaptor_has_simple_extra_args<_Adaptor, _Args...> - && (is_trivially_copyable_v<_Args> && ...) + && (is_trivially_copy_constructible_v<_Args> && ...) struct _Partial<_Adaptor, _Args...> : _RangeAdaptorClosure<_Partial<_Adaptor, _Args...>> { tuple<_Args...> _M_args; @@ -1153,7 +1153,7 @@ namespace views::__adaptor // where _Adaptor accepts a single extra argument. template requires __adaptor_has_simple_extra_args<_Adaptor, _Arg> - && is_trivially_copyable_v<_Arg> + && is_trivially_copy_constructible_v<_Arg> struct _Partial<_Adaptor, _Arg> : _RangeAdaptorClosure<_Partial<_Adaptor, _Arg>> { _Arg _M_arg; diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc index a5791b3da702..772e4b3b6a0d 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc @@ -110,6 +110,7 @@ test04() }; // P2494R2 Relaxing range adaptors to allow for move only types static_assert( requires { views::pairwise_transform(x, move_only{}); } ); + static_assert( requires { x | views::pairwise_transform(move_only{}); } ); } int diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc index e1b74353e632..783b0fba7e1e 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc @@ -191,8 +191,10 @@ test09() #if __cpp_lib_ranges >= 202207L // P2494R2 Relaxing range adaptors to allow for move only types static_assert( requires { transform(x, move_only{}); } ); + static_assert( requires { x | transform(move_only{}); } ); // PR libstdc++/118413 #else static_assert( ! requires { transform(x, move_only{}); } ); + static_assert( ! requires { x | transform(move_only{}); } ); #endif }
[gcc r15-7264] middle-end/118684 - fix fallout of wrong stack local alignment fix
https://gcc.gnu.org/g:7b02b8f65ef60be77f3f93945e2a6b463edaa0aa commit r15-7264-g7b02b8f65ef60be77f3f93945e2a6b463edaa0aa Author: Richard Biener Date: Wed Jan 29 08:58:39 2025 +0100 middle-end/118684 - fix fallout of wrong stack local alignment fix When we expand BIT_FIELD_REF we can end up creating a stack local, running into the fix. But get_object_alignment will return 8 for any SSA_NAME because that's not an "object" we handle. Deal with handled components on registers by singling out SSA_NAME bases, using their type alignment instead of get_object_alignment (I considered "robustifying" get_object_alignment, but decided not to at this point). This fixes an ICE on gcc.dg/pr41123.c on arm as reported by the CI. PR middle-end/118684 * expr.cc (expand_expr_real_1): When creating a stack local during expansion of a handled component, when the base is a SSA_NAME use its type alignment and avoid calling get_object_alignment. * gcc.dg/pr118684.c: Require automatic_stack_alignment. Diff: --- gcc/expr.cc | 4 +++- gcc/testsuite/gcc.dg/pr118684.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/expr.cc b/gcc/expr.cc index 95f41f69fcf2..7f3149b85eec 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -12152,7 +12152,9 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, if (!poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (tem)), &size)) size = max_int_size_in_bytes (TREE_TYPE (tem)); memloc = assign_stack_local (TYPE_MODE (TREE_TYPE (tem)), size, -get_object_alignment (tem)); +TREE_CODE (tem) == SSA_NAME +? TYPE_ALIGN (TREE_TYPE (tem)) +: get_object_alignment (tem)); emit_move_insn (memloc, op0); op0 = memloc; clear_mem_expr = true; diff --git a/gcc/testsuite/gcc.dg/pr118684.c b/gcc/testsuite/gcc.dg/pr118684.c index 08cc24dc0616..28fd76e366dc 100644 --- a/gcc/testsuite/gcc.dg/pr118684.c +++ b/gcc/testsuite/gcc.dg/pr118684.c @@ -1,4 +1,4 @@ -/* { dg-do run } */ +/* { dg-do run { target automatic_stack_alignment } } */ /* { dg-options "-O2" } */ typedef int v4si __attribute__((vector_size(16)));
[gcc r15-7267] RISC-V: Fix incorrect code gen for scalar signed SAT_SUB [PR117688]
https://gcc.gnu.org/g:bfb57d62c743235284f9b31a88c6ceed9971d27a commit r15-7267-gbfb57d62c743235284f9b31a88c6ceed9971d27a Author: Pan Li Date: Thu Jan 23 12:14:43 2025 +0800 RISC-V: Fix incorrect code gen for scalar signed SAT_SUB [PR117688] This patch would like to fix the wroing code generation for the scalar signed SAT_SUB. The input can be QI/HI/SI/DI while the alu like sub can only work on Xmode. Unfortunately we don't have sub/add for non-Xmode like QImode in scalar, thus we need to sign extend to Xmode to ensure we have the correct value before ALU like sub. The gen_lowpart will generate something like lbu which has all zero for highest bits. For example, when 0xff(-1 for QImode) sub 0x1(1 for QImode), we actually want to -1 - 1 = -2, but if there is no sign extend like lbu, we will get 0xff - 1 = 0xfe which is incorrect. Thus, we have to sign extend 0xff(Qmode) to 0x(assume XImode is DImode) before sub in Xmode. The below test suites are passed for this patch. * The rv64gcv fully regression test. PR target/117688 gcc/ChangeLog: * config/riscv/riscv.cc (riscv_expand_sssub): Leverage the helper riscv_extend_to_xmode_reg with SIGN_EXTEND. gcc/testsuite/ChangeLog: * gcc.target/riscv/pr117688.h: Add test helper macro. * gcc.target/riscv/pr117688-sub-run-1-s16.c: New test. * gcc.target/riscv/pr117688-sub-run-1-s32.c: New test. * gcc.target/riscv/pr117688-sub-run-1-s64.c: New test. * gcc.target/riscv/pr117688-sub-run-1-s8.c: New test. Signed-off-by: Pan Li Diff: --- gcc/config/riscv/riscv.cc | 4 ++-- .../gcc.target/riscv/pr117688-sub-run-1-s16.c | 6 ++ .../gcc.target/riscv/pr117688-sub-run-1-s32.c | 6 ++ .../gcc.target/riscv/pr117688-sub-run-1-s64.c | 6 ++ .../gcc.target/riscv/pr117688-sub-run-1-s8.c| 6 ++ gcc/testsuite/gcc.target/riscv/pr117688.h | 21 + 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 8ea31846e879..3b042e2817b8 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -12920,8 +12920,8 @@ riscv_expand_sssub (rtx dest, rtx x, rtx y) machine_mode mode = GET_MODE (dest); unsigned bitsize = GET_MODE_BITSIZE (mode).to_constant (); rtx shift_bits = GEN_INT (bitsize - 1); - rtx xmode_x = gen_lowpart (Xmode, x); - rtx xmode_y = gen_lowpart (Xmode, y); + rtx xmode_x = riscv_extend_to_xmode_reg (x, mode, SIGN_EXTEND); + rtx xmode_y = riscv_extend_to_xmode_reg (y, mode, SIGN_EXTEND); rtx xmode_minus = gen_reg_rtx (Xmode); rtx xmode_xor_0 = gen_reg_rtx (Xmode); rtx xmode_xor_1 = gen_reg_rtx (Xmode); diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s16.c b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s16.c new file mode 100644 index ..7b375bb6c85d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s16.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_SUB_RUN(int16_t, INT16_MIN, INT16_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s32.c b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s32.c new file mode 100644 index ..ba0e8fc8ea5f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s32.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_SUB_RUN(int32_t, INT32_MIN, INT32_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s64.c b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s64.c new file mode 100644 index ..c24c549af308 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s64.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_SUB_RUN(int64_t, INT64_MIN, INT64_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s8.c b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s8.c new file mode 100644 index ..67f9df179a18 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr117688-sub-run-1-s8.c @@ -0,0 +1,6 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99" } */ + +#include "pr117688.h" + +DEFINE_SIGNED_SAT_SUB_RUN(int8_t, INT8_MIN, INT8_MAX) diff --git a/gcc/testsuite/gcc.target/riscv/pr117688.h b/gcc/testsuite/gcc.target/riscv/pr117688.h index 1013a8a80128..3b734ce62ed2 100644 --- a/gcc/testsuite/gcc.target/riscv/pr117688.h +++ b/gcc/testsuite/gcc.target/riscv/pr117688.h @@ -24,4 +24,25 @@ return 0;
[gcc r15-7269] tree-ssa-dce: Avoid creating invalid BBs with no outgoing edge (PR117892)
https://gcc.gnu.org/g:3d07e7bf13d4aec794dd25b5090c139b4d78283d commit r15-7269-g3d07e7bf13d4aec794dd25b5090c139b4d78283d Author: Martin Jambor Date: Wed Jan 29 10:51:08 2025 +0100 tree-ssa-dce: Avoid creating invalid BBs with no outgoing edge (PR117892) Zhendong Su and Michal Jireš found out that our gimple DSE pass can, under fairly specific conditions, remove a noreturn call which then leaves behind a "normal" BB with no successor edges which following passes do not expect. This patch simply tells the pass to leave such calls alone even when they otherwise appear to be dead. Interestingly, our CFG verifier does not report this. I'll put on my todo list to add a test for it in the next stage 1. gcc/ChangeLog: 2025-01-28 Martin Jambor PR tree-optimization/117892 * tree-ssa-dse.cc (dse_optimize_call): Leave control-altering noreturn calls alone. gcc/testsuite/ChangeLog: 2025-01-27 Martin Jambor PR tree-optimization/117892 * gcc.dg/tree-ssa/pr117892.c: New test. * gcc.dg/tree-ssa/pr118517.c: Likewise. co-authored-by: Michal Jireš Diff: --- gcc/testsuite/gcc.dg/tree-ssa/pr117892.c | 17 + gcc/testsuite/gcc.dg/tree-ssa/pr118517.c | 11 +++ gcc/tree-ssa-dse.cc | 6 -- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr117892.c b/gcc/testsuite/gcc.dg/tree-ssa/pr117892.c new file mode 100644 index ..d9b9c15095fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr117892.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + + +volatile int a; +void b(int *c) { + int *d = 0; + *c = 0; + *d = 0; + __builtin_abort(); +} +int main() { + int f; + if (a) +b(&f); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr118517.c b/gcc/testsuite/gcc.dg/tree-ssa/pr118517.c new file mode 100644 index ..3a34f6788a9c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr118517.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-ipa-pure-const" } */ + +void __attribute__((noreturn)) bar(void) { + __builtin_unreachable (); +} + +int p; +void foo() { + if (p) bar(); +} diff --git a/gcc/tree-ssa-dse.cc b/gcc/tree-ssa-dse.cc index 753d7ef148ba..bc632e384841 100644 --- a/gcc/tree-ssa-dse.cc +++ b/gcc/tree-ssa-dse.cc @@ -1396,8 +1396,10 @@ dse_optimize_call (gimple_stmt_iterator *gsi, sbitmap live_bytes) if (!node) return false; - if (stmt_could_throw_p (cfun, stmt) - && !cfun->can_delete_dead_exceptions) + if ((stmt_could_throw_p (cfun, stmt) + && !cfun->can_delete_dead_exceptions) + || ((gimple_call_flags (stmt) & ECF_NORETURN) + && gimple_call_ctrl_altering_p (stmt))) return false; /* If return value is used the call is not dead. */
[gcc r15-7270] split-path: CALL_EXPR can't show up in gimple_assign
https://gcc.gnu.org/g:eafdce175a4e22bebf42e37a94d528eb52f92f16 commit r15-7270-geafdce175a4e22bebf42e37a94d528eb52f92f16 Author: Andrew Pinski Date: Tue Jan 28 12:20:25 2025 -0800 split-path: CALL_EXPR can't show up in gimple_assign While working on split path, I noticed that poor_ifcvt_candidate_code would check for CALL_EXPR but that can't show up in gimple_assign so this removes that check. This could be a very very small compile time improvement. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * gimple-ssa-split-paths.cc (poor_ifcvt_candidate_code): Remove CALL_EXPR handling. Signed-off-by: Andrew Pinski Diff: --- gcc/gimple-ssa-split-paths.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gcc/gimple-ssa-split-paths.cc b/gcc/gimple-ssa-split-paths.cc index 018e59f98cb7..7c5bc1d842c0 100644 --- a/gcc/gimple-ssa-split-paths.cc +++ b/gcc/gimple-ssa-split-paths.cc @@ -138,8 +138,7 @@ poor_ifcvt_candidate_code (enum tree_code code) return (code == MIN_EXPR || code == MAX_EXPR || code == ABS_EXPR - || code == COND_EXPR - || code == CALL_EXPR); + || code == COND_EXPR); } /* Return TRUE if PRED of BB is an poor ifcvt candidate. */
[gcc r15-7271] split-path: Small fix for poor_ifcvt_pred (tsvc s258) [PR118505]
https://gcc.gnu.org/g:dc6b949c553a3be1ce4d6671fb8a9de213ede114 commit r15-7271-gdc6b949c553a3be1ce4d6671fb8a9de213ede114 Author: Andrew Pinski Date: Tue Jan 28 12:00:06 2025 -0800 split-path: Small fix for poor_ifcvt_pred (tsvc s258) [PR118505] After r15-3436-gb2b20b277988ab, poor_ifcvt_pred returns false for the case where the statement could trap but in this case trapping instructions cannot be made unconditional so it is a poor ifcvt. This fixes a small preformance regression with TSVC s258 at `-O3 -ftrapping-math` on aarch64 where ifcvt would not happen and we would still have a branch. On a specific aarch64, we go from 0.145s down to 0.118s. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: PR tree-optimization/118505 * gimple-ssa-split-paths.cc (poor_ifcvt_pred): Return true for trapping statements. Signed-off-by: Andrew Pinski Diff: --- gcc/gimple-ssa-split-paths.cc | 5 + 1 file changed, 5 insertions(+) diff --git a/gcc/gimple-ssa-split-paths.cc b/gcc/gimple-ssa-split-paths.cc index 7c5bc1d842c0..9db73fdcc6d4 100644 --- a/gcc/gimple-ssa-split-paths.cc +++ b/gcc/gimple-ssa-split-paths.cc @@ -160,6 +160,11 @@ poor_ifcvt_pred (basic_block pred, basic_block bb) gimple *stmt = last_and_only_stmt (pred); if (!stmt || gimple_code (stmt) != GIMPLE_ASSIGN) return true; + + /* If the statement could trap, then this is a poor ifcvt candidate. */ + if (gimple_could_trap_p (stmt)) +return true; + tree_code code = gimple_assign_rhs_code (stmt); if (poor_ifcvt_candidate_code (code)) return true;
[gcc r14-11260] testsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles
https://gcc.gnu.org/g:50c111ecd1ae8eb8af0e7938305de7af892ba9ab commit r14-11260-g50c111ecd1ae8eb8af0e7938305de7af892ba9ab Author: Siddhesh Poyarekar Date: Thu Dec 19 08:09:15 2024 -0500 testsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles Denormal behaviour is well defined for IEEE128 long doubles, so XFAIL some gfortran tests only for targets with the IBM128 long double ABI. gcc/testsuite/ChangeLog: PR testsuite/118127 * lib/target-supports.exp (check_effective_target_long_double_is_ibm128): New procedure. * gfortran.dg/default_format_2.f90: xfail for long_double_is_ibm128. * gfortran.dg/default_format_denormal_2.f90: Likewise. * gfortran.dg/large_real_kind_form_io_2.f90: Likewise. Signed-off-by: Siddhesh Poyarekar (cherry picked from commit d4d4e874dee2d5b0abe5ceb9f2a78e5602e86030) Diff: --- gcc/testsuite/gfortran.dg/default_format_2.f90 | 2 +- gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 | 2 +- gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 | 2 +- gcc/testsuite/lib/target-supports.exp | 14 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/default_format_2.f90 b/gcc/testsuite/gfortran.dg/default_format_2.f90 index 5ad7b3a64295..dd04d3aae981 100644 --- a/gcc/testsuite/gfortran.dg/default_format_2.f90 +++ b/gcc/testsuite/gfortran.dg/default_format_2.f90 @@ -1,4 +1,4 @@ -! { dg-do run { xfail powerpc*-apple-darwin* powerpc*-*-linux* } } +! { dg-do run { xfail long_double_is_ibm128 } } ! { dg-require-effective-target fortran_large_real } ! Test XFAILed on these platforms because the system's printf() lacks ! proper support for denormalized long doubles. See PR24685 diff --git a/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 b/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 index e9ccf5e8f61d..ae056d506a29 100644 --- a/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 +++ b/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 @@ -1,4 +1,4 @@ -! { dg-do run { xfail powerpc*-*-* } } +! { dg-do run { xfail long_double_is_ibm128 } } ! { dg-require-effective-target fortran_large_real } ! Test XFAILed on this platform because the system's printf() lacks ! proper support for denormalized long doubles. See PR24685 diff --git a/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 b/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 index 34b8aec462c6..7b5ca645b62b 100644 --- a/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 +++ b/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 @@ -1,4 +1,4 @@ -! { dg-do run { xfail powerpc*-apple-darwin* powerpc*-*-linux* } } +! { dg-do run { xfail long_double_is_ibm128 } } ! Test XFAILed on these platforms because the system's printf() lacks ! proper support for denormalized long doubles. See PR24685 ! { dg-require-effective-target fortran_large_real } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index be303e300dcd..f8856846f02d 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1817,6 +1817,20 @@ proc check_effective_target_fortran_integer_16 { } { }] } +# Check if long double on the target defaults to the IBM extended format. + +proc check_effective_target_long_double_is_ibm128 { } { +if { ![istarget powerpc*-*-*] } { + return 0 +} + +return [check_no_compiler_messages long_double_is_ibm128 assembly { + #ifndef __LONG_DOUBLE_IBM128__ + #error "__LONG_DOUBLE_IBM128__ not defined" + #endif +}] +} + # Return 1 if we can statically link libgfortran, 0 otherwise. # # When the target name changes, replace the cached result.
[gcc r15-7263] c++: Return false from __is_bounded_array for zero-sized arrays [PR118655]
https://gcc.gnu.org/g:3a6ddbf7b241e1cd9f73495ea373b0a12015bb07 commit r15-7263-g3a6ddbf7b241e1cd9f73495ea373b0a12015bb07 Author: Jakub Jelinek Date: Wed Jan 29 09:32:04 2025 +0100 c++: Return false from __is_bounded_array for zero-sized arrays [PR118655] This is basically Marek's PR114479 r14-9759 __is_array fix applied to __is_bounded_array as well. Similarly to that trait, when not using the builtin it returned false for zero sized arrays but when using the builtin it returns true. 2025-01-29 Jakub Jelinek PR c++/118655 * semantics.cc (trait_expr_value) : Return false for zero-sized arrays. * g++.dg/ext/is_bounded_array.C: Extend. Diff: --- gcc/cp/semantics.cc | 9 - gcc/testsuite/g++.dg/ext/is_bounded_array.C | 14 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index e891319f9a99..ad9864c3a91a 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -13165,7 +13165,14 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) || DERIVED_FROM_P (type1, type2))); case CPTK_IS_BOUNDED_ARRAY: - return type_code1 == ARRAY_TYPE && TYPE_DOMAIN (type1); + return (type_code1 == ARRAY_TYPE + && TYPE_DOMAIN (type1) + /* We don't want to report T[0] as being a bounded array type. +This is for compatibility with an implementation of +std::is_bounded_array by template argument deduction, because +compute_array_index_type_loc rejects a zero-size array +in SFINAE context. */ + && !(TYPE_SIZE (type1) && integer_zerop (TYPE_SIZE (type1; case CPTK_IS_CLASS: return NON_UNION_CLASS_TYPE_P (type1); diff --git a/gcc/testsuite/g++.dg/ext/is_bounded_array.C b/gcc/testsuite/g++.dg/ext/is_bounded_array.C index b5fe435de957..63cd4f89091b 100644 --- a/gcc/testsuite/g++.dg/ext/is_bounded_array.C +++ b/gcc/testsuite/g++.dg/ext/is_bounded_array.C @@ -1,4 +1,5 @@ // { dg-do compile { target c++11 } } +// { dg-options "" } #define SA(X) static_assert((X),#X) @@ -14,21 +15,34 @@ class ClassType { }; +constexpr int sz0 = 0; +constexpr int sz2 = 2; + SA_TEST_CATEGORY(__is_bounded_array, int[2], true); SA_TEST_CATEGORY(__is_bounded_array, int[], false); +SA_TEST_CATEGORY(__is_bounded_array, int[0], false); SA_TEST_CATEGORY(__is_bounded_array, int[2][3], true); SA_TEST_CATEGORY(__is_bounded_array, int[][3], false); +SA_TEST_CATEGORY(__is_bounded_array, int[0][3], false); +SA_TEST_CATEGORY(__is_bounded_array, int[3][0], false); SA_TEST_CATEGORY(__is_bounded_array, float*[2], true); SA_TEST_CATEGORY(__is_bounded_array, float*[], false); SA_TEST_CATEGORY(__is_bounded_array, float*[2][3], true); SA_TEST_CATEGORY(__is_bounded_array, float*[][3], false); SA_TEST_CATEGORY(__is_bounded_array, ClassType[2], true); SA_TEST_CATEGORY(__is_bounded_array, ClassType[], false); +SA_TEST_CATEGORY(__is_bounded_array, ClassType[0], false); SA_TEST_CATEGORY(__is_bounded_array, ClassType[2][3], true); SA_TEST_CATEGORY(__is_bounded_array, ClassType[][3], false); +SA_TEST_CATEGORY(__is_bounded_array, ClassType[0][3], false); +SA_TEST_CATEGORY(__is_bounded_array, ClassType[2][0], false); +SA_TEST_CATEGORY(__is_bounded_array, int[sz2], true); +SA_TEST_CATEGORY(__is_bounded_array, int[sz0], false); SA_TEST_CATEGORY(__is_bounded_array, int(*)[2], false); SA_TEST_CATEGORY(__is_bounded_array, int(*)[], false); +SA_TEST_CATEGORY(__is_bounded_array, int(*)[0], false); SA_TEST_CATEGORY(__is_bounded_array, int(&)[2], false); +SA_TEST_CATEGORY(__is_bounded_array, int(&)[0], false); SA_TEST_FN(__is_bounded_array, int(&)[], false); // Sanity check.
[gcc r15-7281] [PR testsuite/116860] Testsuite adjustment for recently added tests
https://gcc.gnu.org/g:15dba7dfba8b7800ac7b74213171e4df9bc32bb9 commit r15-7281-g15dba7dfba8b7800ac7b74213171e4df9bc32bb9 Author: Jeff Law Date: Wed Jan 29 19:42:11 2025 -0700 [PR testsuite/116860] Testsuite adjustment for recently added tests There's two new tests that are dependent on logical-op-non-short-circuit settings. The BZ is reported against ppc64 and ppc64le, but also applies to a goodly number of the other targets. The "regression" fix is trivial, just add the appropriate param to force the behavior we're expecting. I'm committing that fix momentarily. It's been verified on ppc64, ppc64le and x86_64 as well as the various embedded targets in my tester where many FAILS flip to PASS. I'm leaving the bug open without the regression marker as Jakub has noted a couple of improvements that we can and probably should make. PR target/116860 gcc/testsuite * gcc.dg/tree-ssa/fold-xor-and-or.c: Set logical-op-non-short-circuit. * gcc.dg/tree-ssa/fold-xor-or.c: Similarly. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c index e5dc98e7541d..99e83d8e5aae 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-and-or.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-options "-O3 -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */ typedef unsigned long int uint64_t; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c index c55cfbcc84c8..51b7373af0d8 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/fold-xor-or.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-options "-O3 -fdump-tree-optimized --param logical-op-non-short-circuit=1" } */ typedef unsigned long int uint64_t;
[gcc r15-7278] d: give dependency files better filenames [PR118477]
https://gcc.gnu.org/g:d9ac0ad1e9a4ceec2d354ac0368da7462bea5675 commit r15-7278-gd9ac0ad1e9a4ceec2d354ac0368da7462bea5675 Author: Arsen Arsenović Date: Wed Jan 29 21:14:33 2025 +0100 d: give dependency files better filenames [PR118477] Currently, the dependency files for root-file.o and common-file.o were both d/.deps/file.Po, which would cause parallel builds to fail sometimes with: make[3]: Leaving directory '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc' make[3]: Entering directory '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc' mv: cannot stat 'd/.deps/file.TPo': No such file or directory make[3]: *** [/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/gcc-14-20240511/gcc/d/Make-lang.in:421: d/root-file.o] Error 1 shuffle=131581365 Also, this means that dependencies of one of root-file or common-file are missing when developing. After this patch, those two files get assigned dependency files d/.deps/root-file.Po and d/.deps/common-file.Po respectively, so match the actual object files in the d/ subdirectory. There are other files with similar conflicts (mangle-package.o, visitor-package.o for instance). 2025-01-29 Arsen Arsenović Jakub Jelinek PR d/118477 * Make-lang.in (DCOMPILE, DPOSTCOMPILE): Use $(basename $(@F)) instead of $(*F). Co-Authored-By: Jakub Jelinek Diff: --- gcc/d/Make-lang.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in index f28761e4b370..a29531c8b7f6 100644 --- a/gcc/d/Make-lang.in +++ b/gcc/d/Make-lang.in @@ -65,8 +65,8 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \ $(WARN_DFLAGS) DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@ -DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo -DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po +DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(basename $(@F)).TPo +DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).TPo $(@D)/$(DEPDIR)/$(basename $(@F)).Po DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++ # Like LINKER, but use a mutex for serializing front end links.
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression associated_assumed_rank.f90
https://gcc.gnu.org/g:caad7ff152e6581f53132a021916344724a47642 commit caad7ff152e6581f53132a021916344724a47642 Author: Mikael Morin Date: Wed Jan 29 21:14:52 2025 +0100 Correction régression associated_assumed_rank.f90 Diff: --- gcc/fortran/trans-expr.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index d5bf453f61df..860224066167 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -191,6 +191,8 @@ set_descriptor_from_scalar (stmtblock_t *block, tree desc, tree scalar, tree dtype_ref = gfc_conv_descriptor_dtype (desc); gfc_add_modify (block, dtype_ref, dtype_val); + gfc_conv_descriptor_span_set (block, desc, integer_zero_node); + if (CONSTANT_CLASS_P (scalar)) { tree tmp;
[gcc r15-7279] PR modula2/116073 invalid rtl sharing compiling FileSystem.mod caused by ext-dce
https://gcc.gnu.org/g:62abe069506e67d2668e8de7c5e00c118c60d8a7 commit r15-7279-g62abe069506e67d2668e8de7c5e00c118c60d8a7 Author: Gaius Mulley Date: Wed Jan 29 20:32:07 2025 + PR modula2/116073 invalid rtl sharing compiling FileSystem.mod caused by ext-dce The bug fixes to PR modula2/118010 and PR modula2/118183 uncovered a bug in the procedure interface to lseek which uses SYSTEM.COFF_T rather than SYSTEM.CSSIZE_T. This patch sets the default size for COFF_T to the same as CSSIZE_T. gcc/ChangeLog: PR modula2/118010 PR modula2/118183 PR modula2/116073 * doc/gm2.texi (-fm2-file-offset-bits=): Change the default size description to CSSIZE_T. Add COFF_T to the list of data types exported by SYSTEM.def. gcc/m2/ChangeLog: PR modula2/118010 PR modula2/118183 PR modula2/116073 * gm2-compiler/M2Options.mod (OffTBits): Assign to 0. * gm2-gcc/m2type.cc (build_m2_specific_size_type): Ensure that layout_type is called before returning c. (build_m2_offt_type_node): If GetFileOffsetBits returns 0 then use the type size of ssize_t. gcc/testsuite/ChangeLog: PR modula2/118010 PR modula2/118183 PR modula2/116073 * gm2/pim/run/pass/printtypesize.mod: New test. Signed-off-by: Gaius Mulley Diff: --- gcc/doc/gm2.texi | 14 +- gcc/m2/gm2-compiler/M2Options.mod| 2 +- gcc/m2/gm2-gcc/m2type.cc | 8 ++-- gcc/testsuite/gm2/pim/run/pass/printtypesize.mod | 15 +++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi index 5af8b228831f..f8ae148b99ba 100644 --- a/gcc/doc/gm2.texi +++ b/gcc/doc/gm2.texi @@ -502,7 +502,8 @@ the previous forms could be: @item -fm2-file-offset-bits= force the type @code{SYSTEM.COFF_T} to be built using the specified -number of bits. If this option is not used then default is 64 bits. +number of bits. If this option is not used then default is +@code{CSSIZE_T} bits. @item -fm2-g improve the debugging experience for new programmers at the expense @@ -2895,10 +2896,13 @@ base module). PIM-2 defined @code{SIZE} in the @code{SYSTEM} module GNU Modula-2 allows users to specify the dialect of Modula-2 by using the @code{-fiso} and @code{-fpim2} command line switches. -The data types @code{CSIZE_T} and @code{CSSIZE_T} are also exported from -the @code{SYSTEM} module. The type @code{CSIZE_T} is unsigned and is -mapped onto the target C data type @code{size_t} whereas the type -@code{CSSIZE_T} is mapped onto the signed C data type @code{ssize_t}. +The data types @code{CSIZE_T}, @code{CSSIZE_T} and @code{COFF_T} are +also exported from the @code{SYSTEM} module. The type @code{CSIZE_T} +is unsigned and is mapped onto the target C data type @code{size_t} +whereas the type @code{CSSIZE_T} is mapped onto the signed C data type +@code{ssize_t}. The default size for the signed type @code{COFF_T} is +the same as @code{CSSIZE_T} and this can be overridden by the +@code{-fm2-file-offset-bits=} command line option. It is anticipated that these should only be used to provide cross platform definition modules for C libraries. diff --git a/gcc/m2/gm2-compiler/M2Options.mod b/gcc/m2/gm2-compiler/M2Options.mod index 4c03dfeddfba..39f0b2a73fb2 100644 --- a/gcc/m2/gm2-compiler/M2Options.mod +++ b/gcc/m2/gm2-compiler/M2Options.mod @@ -2147,5 +2147,5 @@ BEGIN M2Dump:= NIL ; M2DumpFilter := NIL ; EnableForward := TRUE ; - OffTBits := 64 ; (* Default to 64bit OFF_T. *) + OffTBits := 0 ; (* Default to CSSIZE_T. *) END M2Options. diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc index 9f7a433e9806..a946509d1c25 100644 --- a/gcc/m2/gm2-gcc/m2type.cc +++ b/gcc/m2/gm2-gcc/m2type.cc @@ -1077,7 +1077,6 @@ build_m2_specific_size_type (location_t location, enum tree_code base, { if (!float_mode_for_size (TYPE_PRECISION (c)).exists ()) return NULL; - layout_type (c); } else if (base == SET_TYPE) return build_m2_size_set_type (location, precision); @@ -1096,6 +1095,7 @@ build_m2_specific_size_type (location_t location, enum tree_code base, TYPE_UNSIGNED (c) = true; } } + layout_type (c); return c; } @@ -1385,8 +1385,12 @@ static tree build_m2_offt_type_node (location_t location) { m2assert_AssertLocation (location); + int offt_size = M2Options_GetFileOffsetBits (); + + if (offt_size == 0) +offt_size = TREE_INT_CST_LOW (TYPE_SIZE (ssizetype)); return build_m2_specific_size_type (location, INTEGER_TYPE, - M2Options_Get
[gcc/aoliva/heads/testbase] (107 commits) Daily bump.
The branch 'aoliva/heads/testbase' was updated to point to: 0942ee328dd0... Daily bump. It previously pointed to: 91fa9c15cc4f... [ifcombine] check for more zero-extension cases [PR118572] Diff: Summary of changes (added commits): --- 0942ee3... Daily bump. (*) 62abe06... PR modula2/116073 invalid rtl sharing compiling FileSystem. (*) d9ac0ad... d: give dependency files better filenames [PR118477] (*) a0a202d... pair-fusion: A couple of fixes for sp updates [PR118429] (*) eacb85e... AVR: Allow to share libgcc's __negsi2. (*) 2a77afa... c++: add fixed test [PR57533] (*) d4d4e87... testsuite/118127: Pass fortran tests on ppc64le for IEEE128 (*) 4318821... [PATCH] RX: Restrict displacement ranges in "Q" constraint (*) 09d1cbe... libstdc++: Fix views::transform(move_only_fn{}) forwarding (*) dc6b949... split-path: Small fix for poor_ifcvt_pred (tsvc s258) [PR11 (*) eafdce1... split-path: CALL_EXPR can't show up in gimple_assign (*) 3d07e7b... tree-ssa-dce: Avoid creating invalid BBs with no outgoing e (*) 5a48079... RISC-V: Fix incorrect code gen for scalar signed SAT_TRUNC (*) bfb57d6... RISC-V: Fix incorrect code gen for scalar signed SAT_SUB [P (*) 81aa948... RISC-V: Fix incorrect code gen for scalar signed SAT_ADD [P (*) 7ab7829... RISC-V: Refactor SAT_* operand rtx extend to reg help func (*) 7b02b8f... middle-end/118684 - fix fallout of wrong stack local alignm (*) 3a6ddbf... c++: Return false from __is_bounded_array for zero-sized ar (*) 5d001fa... Fortran: fix passing of component ref to assumed-rank dummy (*) 2abc555... Daily bump. (*) c3b0b98... c++: constexpr VEC_INIT_EXPR [PR118285] (*) d0f230a... c++: init-list opt and lvalue initializers [PR118673] (*) 0204dcf... arm: libgcc: make -spec=sync-*.specs compatible with LTO [P (*) 54bdeca... middle-end/118684 - wrongly aligned stack local during expa (*) 50c3751... input.cc: show line record indices in file_cache_slot::dump (*) b4bd067... sarif output: escape braces in messages [PR118675] (*) 98b2009... vect: Fix permutation counting in VLA-friendly path [PR1172 (*) ea578dd... c++: friend vs inherited guide confusion [PR117855] (*) 3ccbc8c... tree-optimization/112859 - add comment (*) a235c45... arm: libbacktrace: Check if the compiler supports __sync at (*) 01339d2... [PR118663][LRA]: Change secondary memory mode only if there (*) f1e776c... tree-optimization/117424 - invalid LIM of trapping ref (*) d6e66e7... Clarify 'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P' in 'gcc/tree-pr (*) 846f086... Remove ChangeLog entry that shouldn't be there. (*) b529a41... combine: Fix up make_extraction [PR118638] (*) 1152555... Add tests for implied copy of variables in reduction clause (*) fc1f717... vect: Remove extra newline from dump message (*) efd2153... c: For array element type drop qualifiers but keep other pr (*) 2352153... [PR target/114085] Fix H8 constraint issue which led to ICE (*) b9871e3... Daily bump. (*) c7f1680... c++: only strip conversions for deduction [PR118632] (*) 019fe9c... RISC-V: Add another test for FRM elimination bug [PR118646] (*) ceabea4... c++: Don't prune constant capture proxies only used in arra (*) f7dc4fd... RISC-V: testsuite: Fix reduc-8.c and reduc-9.c (*) c0c2304... RISC-V: testsuite: Fix gather_load_64-12-zvbb.c (*) 006b4e4... RISC-V: Disable two-source permutes for now [PR117173]. (*) 9104472... Fortran: fix bogus diagnostics on renamed interface import (*) 9d450de... c++: Use mapped reads and writes when munmap and msync are (*) d31667e... Remove mistakenly committed files (*) f4d7723... c++: Handle CWG2867 even in namespace scope structured bind (*) ad8e6a4... c++: Implement for namespace statics CWG 2867 - Order of in (*) 6a510de... tree-optimization/118653 - ICE in vectorizable_live_operati (*) c6977f7... libstdc++: correct symbol version of typeinfo for bfloat16_ (*) 343e108... rtl-optimization/118662 - wrong combination of vector sign- (*) 5236635... middle-end/118643 - ICE with out-of-bound decl access (*) 04ba130... tree-optimization/112859 - bogus loop distribution (*) 3600b1f... Fortran: ICE in gfc_conv_expr_present w. defined assignment (*) 92a5c51... match.pd: Canonicalize unsigned division by power of two in (*) d8a7f07... match.pd: Fix indefinite recursion during exp-log transform (*) 1110ed7... Daily bump. (*) 7cd133a... Fortran: In openmp.cc, uncomment unroll/tile lines of gfc_o (*) bcbbce2... modula2: Tidyup gm2-compiler/M2GenGCC.mod:FoldConstBecomes (*) 13d9716... asan: Fix missing FakeStack flag cleanup (*) 50fb72d... OpenMP: Fix typo in atomic directive error message (*) 1c470cc... modula2: comment tidyup and parameter rename (*) 55d288d... RISC-V: Make FRM as global register [PR118103] (*) 0710024... Daily bump. (*) 765769d... [PR modula2/118010, modula2/118183] Rebuild bootstrap tools (*) 8fd2158... Fortran: fix issues with variab
[gcc/aoliva/heads/testme] (109 commits) [testsuite] require -Ofast for vect-ifcvt-18 even without a
The branch 'aoliva/heads/testme' was updated to point to: 06269f83b828... [testsuite] require -Ofast for vect-ifcvt-18 even without a It previously pointed to: c3039567c413... [ifcombine] avoid creating out-of-bounds BIT_FIELD_REFs [PR Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- c303956... [ifcombine] avoid creating out-of-bounds BIT_FIELD_REFs [PR Summary of changes (added commits): --- 06269f8... [testsuite] require -Ofast for vect-ifcvt-18 even without a eb3bc62... [testsuite] require profiling support [PR113689] 0942ee3... Daily bump. (*) 62abe06... PR modula2/116073 invalid rtl sharing compiling FileSystem. (*) d9ac0ad... d: give dependency files better filenames [PR118477] (*) a0a202d... pair-fusion: A couple of fixes for sp updates [PR118429] (*) eacb85e... AVR: Allow to share libgcc's __negsi2. (*) 2a77afa... c++: add fixed test [PR57533] (*) d4d4e87... testsuite/118127: Pass fortran tests on ppc64le for IEEE128 (*) 4318821... [PATCH] RX: Restrict displacement ranges in "Q" constraint (*) 09d1cbe... libstdc++: Fix views::transform(move_only_fn{}) forwarding (*) dc6b949... split-path: Small fix for poor_ifcvt_pred (tsvc s258) [PR11 (*) eafdce1... split-path: CALL_EXPR can't show up in gimple_assign (*) 3d07e7b... tree-ssa-dce: Avoid creating invalid BBs with no outgoing e (*) 5a48079... RISC-V: Fix incorrect code gen for scalar signed SAT_TRUNC (*) bfb57d6... RISC-V: Fix incorrect code gen for scalar signed SAT_SUB [P (*) 81aa948... RISC-V: Fix incorrect code gen for scalar signed SAT_ADD [P (*) 7ab7829... RISC-V: Refactor SAT_* operand rtx extend to reg help func (*) 7b02b8f... middle-end/118684 - fix fallout of wrong stack local alignm (*) 3a6ddbf... c++: Return false from __is_bounded_array for zero-sized ar (*) 5d001fa... Fortran: fix passing of component ref to assumed-rank dummy (*) 2abc555... Daily bump. (*) c3b0b98... c++: constexpr VEC_INIT_EXPR [PR118285] (*) d0f230a... c++: init-list opt and lvalue initializers [PR118673] (*) 0204dcf... arm: libgcc: make -spec=sync-*.specs compatible with LTO [P (*) 54bdeca... middle-end/118684 - wrongly aligned stack local during expa (*) 50c3751... input.cc: show line record indices in file_cache_slot::dump (*) b4bd067... sarif output: escape braces in messages [PR118675] (*) 98b2009... vect: Fix permutation counting in VLA-friendly path [PR1172 (*) ea578dd... c++: friend vs inherited guide confusion [PR117855] (*) 3ccbc8c... tree-optimization/112859 - add comment (*) a235c45... arm: libbacktrace: Check if the compiler supports __sync at (*) 01339d2... [PR118663][LRA]: Change secondary memory mode only if there (*) f1e776c... tree-optimization/117424 - invalid LIM of trapping ref (*) d6e66e7... Clarify 'OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P' in 'gcc/tree-pr (*) 846f086... Remove ChangeLog entry that shouldn't be there. (*) b529a41... combine: Fix up make_extraction [PR118638] (*) 1152555... Add tests for implied copy of variables in reduction clause (*) fc1f717... vect: Remove extra newline from dump message (*) efd2153... c: For array element type drop qualifiers but keep other pr (*) 2352153... [PR target/114085] Fix H8 constraint issue which led to ICE (*) b9871e3... Daily bump. (*) c7f1680... c++: only strip conversions for deduction [PR118632] (*) 019fe9c... RISC-V: Add another test for FRM elimination bug [PR118646] (*) ceabea4... c++: Don't prune constant capture proxies only used in arra (*) f7dc4fd... RISC-V: testsuite: Fix reduc-8.c and reduc-9.c (*) c0c2304... RISC-V: testsuite: Fix gather_load_64-12-zvbb.c (*) 006b4e4... RISC-V: Disable two-source permutes for now [PR117173]. (*) 9104472... Fortran: fix bogus diagnostics on renamed interface import (*) 9d450de... c++: Use mapped reads and writes when munmap and msync are (*) d31667e... Remove mistakenly committed files (*) f4d7723... c++: Handle CWG2867 even in namespace scope structured bind (*) ad8e6a4... c++: Implement for namespace statics CWG 2867 - Order of in (*) 6a510de... tree-optimization/118653 - ICE in vectorizable_live_operati (*) c6977f7... libstdc++: correct symbol version of typeinfo for bfloat16_ (*) 343e108... rtl-optimization/118662 - wrong combination of vector sign- (*) 5236635... middle-end/118643 - ICE with out-of-bound decl access (*) 04ba130... tree-optimization/112859 - bogus loop distribution (*) 3600b1f... Fortran: ICE in gfc_conv_expr_present w. defined assignment (*) 92a5c51... match.pd: Canonicalize unsigned division by power of two in (*) d8a7f07... match.pd: Fix indefinite recursion during exp-log transform (*) 1110ed7... Daily bump. (*) 7cd133a... Fortran: In openmp.cc, uncomment unroll/tile lines of gfc_o (*) bcbbce2... modula2: Tidyup gm2-compiler/M2GenGCC.mod:FoldConstBecomes (*) 13d971
[gcc(refs/users/aoliva/heads/testme)] [testsuite] require profiling support [PR113689]
https://gcc.gnu.org/g:eb3bc62fb98be4b86253d7b72a5b03456e61356d commit eb3bc62fb98be4b86253d7b72a5b03456e61356d Author: Alexandre Oliva Date: Thu Jan 30 02:58:15 2025 -0300 [testsuite] require profiling support [PR113689] Diff: --- gcc/testsuite/gcc.target/i386/pr113689-1.c | 1 + gcc/testsuite/gcc.target/i386/pr113689-2.c | 1 + gcc/testsuite/gcc.target/i386/pr113689-3.c | 1 + 3 files changed, 3 insertions(+) diff --git a/gcc/testsuite/gcc.target/i386/pr113689-1.c b/gcc/testsuite/gcc.target/i386/pr113689-1.c index 0424db2dfdca..0ed911393eea 100644 --- a/gcc/testsuite/gcc.target/i386/pr113689-1.c +++ b/gcc/testsuite/gcc.target/i386/pr113689-1.c @@ -1,5 +1,6 @@ /* { dg-do run { target { lp64 && fpic } } } */ /* { dg-options "-O2 -fno-pic -no-pie -fprofile -mcmodel=large" } */ +/* { dg-require-profiling "-fprofile" } */ /* { dg-skip-if "PR90698" { *-*-darwin* } } */ /* { dg-skip-if "PR113909" { *-*-solaris2* } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr113689-2.c b/gcc/testsuite/gcc.target/i386/pr113689-2.c index 58688b9a387c..decc44a44fb5 100644 --- a/gcc/testsuite/gcc.target/i386/pr113689-2.c +++ b/gcc/testsuite/gcc.target/i386/pr113689-2.c @@ -1,5 +1,6 @@ /* { dg-do run { target { lp64 && fpic } } } */ /* { dg-options "-O2 -fpic -fprofile -mcmodel=large" } */ +/* { dg-require-profiling "-fprofile" } */ /* { dg-skip-if "PR90698" { *-*-darwin* } } */ /* { dg-skip-if "PR113909" { *-*-solaris2* } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr113689-3.c b/gcc/testsuite/gcc.target/i386/pr113689-3.c index 14c906239f9d..a904feec13f0 100644 --- a/gcc/testsuite/gcc.target/i386/pr113689-3.c +++ b/gcc/testsuite/gcc.target/i386/pr113689-3.c @@ -1,5 +1,6 @@ /* { dg-do run { target { lp64 && fpic } } } */ /* { dg-options "-O2 -fpic -fprofile -mcmodel=large" } */ +/* { dg-require-profiling "-fprofile" } */ /* { dg-skip-if "PR90698" { *-*-darwin* } } */ /* { dg-skip-if "PR113909" { *-*-solaris2* } } */
[gcc(refs/users/aoliva/heads/testme)] [testsuite] require -Ofast for vect-ifcvt-18 even without avx
https://gcc.gnu.org/g:06269f83b82886b81b7b54cc56c8fcb7a97c7739 commit 06269f83b82886b81b7b54cc56c8fcb7a97c7739 Author: Alexandre Oliva Date: Thu Jan 30 02:59:06 2025 -0300 [testsuite] require -Ofast for vect-ifcvt-18 even without avx Diff: --- gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c index c1d3c27d8193..228011ae07bc 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c +++ b/gcc/testsuite/gcc.dg/vect/vect-ifcvt-18.c @@ -1,6 +1,7 @@ /* { dg-require-effective-target vect_condition } */ /* { dg-require-effective-target vect_float } */ -/* { dg-additional-options "-Ofast -mavx" { target avx_runtime } } */ +/* { dg-additional-options "-Ofast" { target i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ int A0[4] = {36,39,42,45};
[gcc r15-7272] libstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413]
https://gcc.gnu.org/g:09d1cbee10b8c51aed48f047f30717f622d6f811 commit r15-7272-g09d1cbee10b8c51aed48f047f30717f622d6f811 Author: Patrick Palka Date: Wed Jan 29 10:02:28 2025 -0500 libstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413] The range adaptor perfect forwarding simplification mechanism is currently only enabled for trivially copyable bound arguments, to prevent undesirable copies of complex objects. But "trivially copyable" is the wrong property to check for here, since a move-only type with a trivial move constructor is considered trivially copyable, and after P2492R2 we can't assume copy constructibility of the bound arguments. This patch makes the mechanism more specifically check for trivial copy constructibility instead so that it's properly disabled for move-only bound arguments. PR libstdc++/118413 libstdc++-v3/ChangeLog: * include/std/ranges (views::__adaptor::_Partial): Adjust constraints on the "simple" partial specializations to require is_trivially_copy_constructible_v instead of is_trivially_copyable_v. * testsuite/std/ranges/adaptors/adjacent_transform/1.cc (test04): Extend P2494R2 test. * testsuite/std/ranges/adaptors/transform.cc (test09): Likewise. Reviewed-by: Jonathan Wakely Diff: --- libstdc++-v3/include/std/ranges| 4 ++-- libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc | 1 + libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc| 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index ad69a94b21fb..5c795a90fbc2 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -1145,7 +1145,7 @@ namespace views::__adaptor // which makes overload resolution failure diagnostics more concise. template requires __adaptor_has_simple_extra_args<_Adaptor, _Args...> - && (is_trivially_copyable_v<_Args> && ...) + && (is_trivially_copy_constructible_v<_Args> && ...) struct _Partial<_Adaptor, _Args...> : _RangeAdaptorClosure<_Partial<_Adaptor, _Args...>> { tuple<_Args...> _M_args; @@ -1176,7 +1176,7 @@ namespace views::__adaptor // where _Adaptor accepts a single extra argument. template requires __adaptor_has_simple_extra_args<_Adaptor, _Arg> - && is_trivially_copyable_v<_Arg> + && is_trivially_copy_constructible_v<_Arg> struct _Partial<_Adaptor, _Arg> : _RangeAdaptorClosure<_Partial<_Adaptor, _Arg>> { _Arg _M_arg; diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc index a5791b3da702..772e4b3b6a0d 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent_transform/1.cc @@ -110,6 +110,7 @@ test04() }; // P2494R2 Relaxing range adaptors to allow for move only types static_assert( requires { views::pairwise_transform(x, move_only{}); } ); + static_assert( requires { x | views::pairwise_transform(move_only{}); } ); } int diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc index dfc91fb5e1fb..934d2f65dcf0 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/transform.cc @@ -191,8 +191,10 @@ test09() #if __cpp_lib_ranges >= 202207L // P2494R2 Relaxing range adaptors to allow for move only types static_assert( requires { transform(x, move_only{}); } ); + static_assert( requires { x | transform(move_only{}); } ); // PR libstdc++/118413 #else static_assert( ! requires { transform(x, move_only{}); } ); + static_assert( ! requires { x | transform(move_only{}); } ); #endif }
[gcc r15-7273] [PATCH] RX: Restrict displacement ranges in "Q" constraint
https://gcc.gnu.org/g:4318821562638a3d909942f561a42f7272ddfed4 commit r15-7273-g4318821562638a3d909942f561a42f7272ddfed4 Author: Yoshinori Sato Date: Wed Jan 29 08:07:15 2025 -0700 [PATCH] RX: Restrict displacement ranges in "Q" constraint When using the "Q" constraint in the inline assembler, the displacement value could exceed the range specified by the instruction. To avoid this issue, a displacement range check is added to the "Q" constraint. gcc/ * config/rx/constraints.md (Q): Also check that the address passes rx_is_restricted_memory-address. Diff: --- gcc/config/rx/constraints.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/config/rx/constraints.md b/gcc/config/rx/constraints.md index 4fc242667ab4..4b81ae6aa75b 100644 --- a/gcc/config/rx/constraints.md +++ b/gcc/config/rx/constraints.md @@ -80,7 +80,8 @@ (ior (match_code "reg" "0") (and (match_code "plus" "0") (and (match_code "reg,subreg" "00") - (match_code "const_int" "01") + (and (match_code "const_int" "01") + (match_test "rx_is_restricted_memory_address (XEXP (op, 0), mode)")) ) ) )
[gcc r15-7274] testsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles
https://gcc.gnu.org/g:d4d4e874dee2d5b0abe5ceb9f2a78e5602e86030 commit r15-7274-gd4d4e874dee2d5b0abe5ceb9f2a78e5602e86030 Author: Siddhesh Poyarekar Date: Thu Dec 19 08:09:15 2024 -0500 testsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles Denormal behaviour is well defined for IEEE128 long doubles, so XFAIL some gfortran tests only for targets with the IBM128 long double ABI. gcc/testsuite/ChangeLog: PR testsuite/118127 * lib/target-supports.exp (check_effective_target_long_double_is_ibm128): New procedure. * gfortran.dg/default_format_2.f90: xfail for long_double_is_ibm128. * gfortran.dg/default_format_denormal_2.f90: Likewise. * gfortran.dg/large_real_kind_form_io_2.f90: Likewise. Signed-off-by: Siddhesh Poyarekar Diff: --- gcc/testsuite/gfortran.dg/default_format_2.f90 | 2 +- gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 | 2 +- gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 | 2 +- gcc/testsuite/lib/target-supports.exp | 14 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/default_format_2.f90 b/gcc/testsuite/gfortran.dg/default_format_2.f90 index 5ad7b3a64295..dd04d3aae981 100644 --- a/gcc/testsuite/gfortran.dg/default_format_2.f90 +++ b/gcc/testsuite/gfortran.dg/default_format_2.f90 @@ -1,4 +1,4 @@ -! { dg-do run { xfail powerpc*-apple-darwin* powerpc*-*-linux* } } +! { dg-do run { xfail long_double_is_ibm128 } } ! { dg-require-effective-target fortran_large_real } ! Test XFAILed on these platforms because the system's printf() lacks ! proper support for denormalized long doubles. See PR24685 diff --git a/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 b/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 index e9ccf5e8f61d..ae056d506a29 100644 --- a/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 +++ b/gcc/testsuite/gfortran.dg/default_format_denormal_2.f90 @@ -1,4 +1,4 @@ -! { dg-do run { xfail powerpc*-*-* } } +! { dg-do run { xfail long_double_is_ibm128 } } ! { dg-require-effective-target fortran_large_real } ! Test XFAILed on this platform because the system's printf() lacks ! proper support for denormalized long doubles. See PR24685 diff --git a/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 b/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 index 34b8aec462c6..7b5ca645b62b 100644 --- a/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 +++ b/gcc/testsuite/gfortran.dg/large_real_kind_form_io_2.f90 @@ -1,4 +1,4 @@ -! { dg-do run { xfail powerpc*-apple-darwin* powerpc*-*-linux* } } +! { dg-do run { xfail long_double_is_ibm128 } } ! Test XFAILed on these platforms because the system's printf() lacks ! proper support for denormalized long doubles. See PR24685 ! { dg-require-effective-target fortran_large_real } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 9ad1e1965bbd..60e24129bd58 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1854,6 +1854,20 @@ proc check_effective_target_fortran_integer_16 { } { }] } +# Check if long double on the target defaults to the IBM extended format. + +proc check_effective_target_long_double_is_ibm128 { } { +if { ![istarget powerpc*-*-*] } { + return 0 +} + +return [check_no_compiler_messages long_double_is_ibm128 assembly { + #ifndef __LONG_DOUBLE_IBM128__ + #error "__LONG_DOUBLE_IBM128__ not defined" + #endif +}] +} + # Return 1 if we can statically link libgfortran, 0 otherwise. # # When the target name changes, replace the cached result.
[gcc r13-9354] c++: re-enable NSDMI CONSTRUCTOR folding [PR118355]
https://gcc.gnu.org/g:445203466749b8bdd17590fe7dd37d72d8b570c0 commit r13-9354-g445203466749b8bdd17590fe7dd37d72d8b570c0 Author: Marek Polacek Date: Mon Jan 13 15:09:14 2025 -0500 c++: re-enable NSDMI CONSTRUCTOR folding [PR118355] In c++/102990 we had a problem where massage_init_elt got {}, digest_nsdmi_init turned that {} into { .value = (int) 1.0e+0 }, and we crashed in the call to fold_non_dependent_init because a FIX_TRUNC_EXPR/FLOAT_EXPR got into tsubst*. So we avoided calling fold_non_dependent_init for a CONSTRUCTOR. But that broke the following test, where we no longer fold the CONST_DECL in { .type = ZERO } to { .type = 0 } and then process_init_constructor_array does: if (next != error_mark_node && (initializer_constant_valid_p (next, TREE_TYPE (next)) != null_pointer_node)) { /* Use VEC_INIT_EXPR for non-constant initialization of trailing elements with no explicit initializers. */ picflags |= PICFLAG_VEC_INIT; because { .type = ZERO } isn't initializer_constant_valid_p. Then we create a VEC_INIT_EXPR and say we can't convert the argument. So we have to fold the elements of the CONSTRUCTOR. We just can't instantiate the elements in a template. This also fixes c++/118047. PR c++/118047 PR c++/118355 gcc/cp/ChangeLog: * typeck2.cc (massage_init_elt): Call fold_non_dependent_init unless for a CONSTRUCTOR in a template. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/nsdmi-list10.C: New test. * g++.dg/cpp0x/nsdmi-list9.C: New test. Reviewed-by: Jason Merrill (cherry picked from commit e939005c496dfd4058fa57b6860bfadcabe4a111) Diff: --- gcc/cp/typeck2.cc | 8 +++ gcc/testsuite/g++.dg/cpp0x/nsdmi-list10.C | 35 +++ gcc/testsuite/g++.dg/cpp0x/nsdmi-list9.C | 34 ++ 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc index 27263f503f18..e499bf0f20ce 100644 --- a/gcc/cp/typeck2.cc +++ b/gcc/cp/typeck2.cc @@ -1528,10 +1528,10 @@ massage_init_elt (tree type, tree init, int nested, int flags, new_flags |= LOOKUP_AGGREGATE_PAREN_INIT; init = digest_init_r (type, init, nested ? 2 : 1, new_flags, complain); /* When we defer constant folding within a statement, we may want to - defer this folding as well. Don't call this on CONSTRUCTORs because - their elements have already been folded, and we must avoid folding - the result of get_nsdmi. */ - if (TREE_CODE (init) != CONSTRUCTOR) + defer this folding as well. Don't call this on CONSTRUCTORs in + a template because their elements have already been folded, and + we must avoid folding the result of get_nsdmi. */ + if (!(processing_template_decl && TREE_CODE (init) == CONSTRUCTOR)) { tree t = fold_non_dependent_init (init, complain); if (TREE_CONSTANT (t)) diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list10.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list10.C new file mode 100644 index ..36b74749cbf6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list10.C @@ -0,0 +1,35 @@ +// PR c++/118047 +// { dg-do compile { target c++11 } } + +typedef decltype(sizeof(char)) size_t; + +namespace std { +template +struct initializer_list { + const T *_M_array; + size_t _M_len; + constexpr size_t size() const { return _M_len; } +}; +} + +enum E { +One +}; + +struct A { +E e = One; +}; + +struct B { +A as[1] {}; +}; + +struct V +{ + constexpr V(const std::initializer_list &a) : size(a.size()){} + int size; +}; + +constexpr V a{{}}; + +static_assert(a.size == 1, ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list9.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list9.C new file mode 100644 index ..ae69ba0810dc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list9.C @@ -0,0 +1,34 @@ +// PR c++/118355 +// { dg-do compile { target c++11 } } + +enum MY_ENUM +{ + ZERO, +}; + +struct FOO +{ + MY_ENUM type = ZERO; +}; + +struct ARR +{ + FOO array[1] = {}; +}; + +template +struct ARR2 +{ + FOO array[1] = {}; +}; + +void +g () +{ + + ARR arr; + arr = {}; + + ARR2 arr2; + arr2 = {}; +}
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Factorisation set_descriptor_from_scalar dans gfc_conv_scalar_to_descriptor
https://gcc.gnu.org/g:ab894026de092d2bc04a8fa55ed4b77983db0d34 commit ab894026de092d2bc04a8fa55ed4b77983db0d34 Author: Mikael Morin Date: Wed Jan 29 19:05:04 2025 +0100 Factorisation set_descriptor_from_scalar dans gfc_conv_scalar_to_descriptor Diff: --- gcc/fortran/trans-expr.cc | 57 --- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 091e1417faed..7ff6a33e5e1b 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -174,46 +174,53 @@ gfc_conv_null_array_descriptor (gfc_se *se, gfc_symbol *sym, gfc_expr *expr) void set_descriptor_from_scalar (stmtblock_t *block, tree desc, tree scalar, - gfc_expr *scalar_expr, bool is_class, + symbol_attribute scalar_attr, bool is_class, tree cond_optional) { - tree type = get_scalar_to_descriptor_type (scalar, -gfc_expr_attr (scalar_expr)); + tree type = get_scalar_to_descriptor_type (scalar, scalar_attr); if (POINTER_TYPE_P (type)) type = TREE_TYPE (type); + if (CONSTANT_CLASS_P (scalar)) +{ + tree tmp; + tmp = gfc_create_var (TREE_TYPE (scalar), "scalar"); + gfc_add_modify (block, tmp, scalar); + scalar = tmp; +} + tree dtype_val = gfc_get_dtype (type); tree dtype_ref = gfc_conv_descriptor_dtype (desc); gfc_add_modify (block, dtype_ref, dtype_val); tree tmp; if (is_class) +tmp = gfc_class_data_get (scalar); + else +tmp = scalar; + + if (!POINTER_TYPE_P (TREE_TYPE (tmp))) +tmp = gfc_build_addr_expr (NULL_TREE, tmp); + + if (cond_optional) { - tmp = gfc_class_data_get (scalar); - if (!POINTER_TYPE_P (TREE_TYPE (tmp))) - tmp = gfc_build_addr_expr (NULL_TREE, tmp); -} - else if (cond_optional) -{ - tmp = build3_loc (input_location, COND_EXPR, TREE_TYPE (scalar), - cond_optional, scalar, + tmp = build3_loc (input_location, COND_EXPR, TREE_TYPE (tmp), + cond_optional, tmp, fold_convert (TREE_TYPE (scalar), null_pointer_node)); } - else -tmp = scalar; gfc_conv_descriptor_data_set (block, desc, tmp); } + tree gfc_conv_scalar_to_descriptor (gfc_se *se, tree scalar, symbol_attribute attr) { - tree desc, type, etype; + tree desc, type; type = get_scalar_to_descriptor_type (scalar, attr); - etype = TREE_TYPE (scalar); desc = gfc_create_var (type, "desc"); DECL_ARTIFICIAL (desc) = 1; @@ -224,15 +231,9 @@ gfc_conv_scalar_to_descriptor (gfc_se *se, tree scalar, symbol_attribute attr) gfc_add_modify (&se->pre, tmp, scalar); scalar = tmp; } - if (!POINTER_TYPE_P (TREE_TYPE (scalar))) -scalar = gfc_build_addr_expr (NULL_TREE, scalar); - else if (TREE_TYPE (etype) && TREE_CODE (TREE_TYPE (etype)) == ARRAY_TYPE) -etype = TREE_TYPE (etype); - gfc_add_modify (&se->pre, gfc_conv_descriptor_dtype (desc), - gfc_get_dtype_rank_type (0, etype)); - gfc_conv_descriptor_data_set (&se->pre, desc, scalar); - gfc_conv_descriptor_span_set (&se->pre, desc, - gfc_conv_descriptor_elem_len (desc)); + + set_descriptor_from_scalar (&se->pre, desc, scalar, attr, + false, NULL_TREE); /* Copy pointer address back - but only if it could have changed and if the actual argument is a pointer and not, e.g., NULL(). */ @@ -1082,8 +1083,8 @@ gfc_conv_derived_to_class (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym, /* Scalar to an assumed-rank array. */ if (fsym->ts.u.derived->components->as) set_descriptor_from_scalar (&parmse->pre, ctree, - parmse->expr, e, false, - cond_optional); + parmse->expr, gfc_expr_attr (e), + false, cond_optional); else { tmp = fold_convert (TREE_TYPE (ctree), parmse->expr); @@ -1458,8 +1459,8 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts, && e->rank != class_ts.u.derived->components->as->rank) { if (e->rank == 0) - set_descriptor_from_scalar (&block, ctree, parmse->expr, e, - true, NULL_TREE); + set_descriptor_from_scalar (&block, ctree, parmse->expr, + gfc_expr_attr (e), true, NULL_TREE); else gfc_class_array_data_assign (&block, ctree, parmse->expr, false); }
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression pr49213.f90
https://gcc.gnu.org/g:243347ea3599e0be1251f158b4a3e06831ed950e commit 243347ea3599e0be1251f158b4a3e06831ed950e Author: Mikael Morin Date: Wed Jan 29 20:33:12 2025 +0100 Correction régression pr49213.f90 Diff: --- gcc/fortran/trans-expr.cc | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 7ff6a33e5e1b..d5bf453f61df 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -181,6 +181,16 @@ set_descriptor_from_scalar (stmtblock_t *block, tree desc, tree scalar, if (POINTER_TYPE_P (type)) type = TREE_TYPE (type); + tree etype = gfc_get_element_type (type); + tree dtype_val; + if (etype == void_type_node) +dtype_val = gfc_get_dtype_rank_type (0, TREE_TYPE (scalar)); + else +dtype_val = gfc_get_dtype (type); + + tree dtype_ref = gfc_conv_descriptor_dtype (desc); + gfc_add_modify (block, dtype_ref, dtype_val); + if (CONSTANT_CLASS_P (scalar)) { tree tmp; @@ -189,10 +199,6 @@ set_descriptor_from_scalar (stmtblock_t *block, tree desc, tree scalar, scalar = tmp; } - tree dtype_val = gfc_get_dtype (type); - tree dtype_ref = gfc_conv_descriptor_dtype (desc); - gfc_add_modify (block, dtype_ref, dtype_val); - tree tmp; if (is_class) tmp = gfc_class_data_get (scalar);
[gcc r15-7275] c++: add fixed test [PR57533]
https://gcc.gnu.org/g:2a77afa0ee41cb8a3664679dcd4545ccd1aa3b35 commit r15-7275-g2a77afa0ee41cb8a3664679dcd4545ccd1aa3b35 Author: Marek Polacek Date: Wed Jan 29 10:37:50 2025 -0500 c++: add fixed test [PR57533] Fixed by r11-2412. PR c++/57533 gcc/testsuite/ChangeLog: * g++.dg/eh/throw5.C: New test. Diff: --- gcc/testsuite/g++.dg/eh/throw5.C | 23 +++ 1 file changed, 23 insertions(+) diff --git a/gcc/testsuite/g++.dg/eh/throw5.C b/gcc/testsuite/g++.dg/eh/throw5.C new file mode 100644 index ..554e8700df00 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/throw5.C @@ -0,0 +1,23 @@ +// PR c++/57533 +// { dg-do run { target c++11 } } + +struct X +{ +bool moved = false; + +X() = default; +X(const X&) = default; +X(X&& x) { x.moved = true; } +}; + +int main() +{ +X x; +try { +throw x; +} +catch(...) { +} +if (x.moved) +__builtin_abort(); +}
[gcc r15-7277] pair-fusion: A couple of fixes for sp updates [PR118429]
https://gcc.gnu.org/g:a0a202d07339ff55793029b5bde152c38b90aaf5 commit r15-7277-ga0a202d07339ff55793029b5bde152c38b90aaf5 Author: Richard Sandiford Date: Wed Jan 29 17:44:53 2025 + pair-fusion: A couple of fixes for sp updates [PR118429] The PR showed two issues with pair-fusion. The first is that the pass treated stack pointer deallocations as ordinary register updates, and so might move them earlier than another stack access (through a different base register) that doesn't alias the pair candidate. The simplest fix for that seems to be to prevent the stack deallocation from being moved. This part might (or might not) be a latent source of wrong code and so worth backporting in some form. (The patch as-is won't work for GCC 14.) The second issue only started with r15-6551, which added a memory write to stack allocations and deallocations. We should use the existing tombstone mechanism to preserve the associated memory definition. (Deleting definitions immediately would have quadratic complexity in the worst case.) gcc/ PR rtl-optimization/118429 * pair-fusion.cc (latest_hazard_before): Add an extra parameter to say whether the instruction is a load or a store. If the instruction is not a load or store and has memory side effects, prevent it from being moved earlier. (pair_fusion::find_trailing_add): Update call accordingly. (pair_fusion_bb_info::fuse_pair): If the trailng addition had a memory side-effect, use a tombstone to preserve it. gcc/testsuite/ PR rtl-optimization/118429 * gcc.c-torture/compile/pr118429.c: New test. Diff: --- gcc/pair-fusion.cc | 45 +++--- gcc/testsuite/gcc.c-torture/compile/pr118429.c | 7 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/gcc/pair-fusion.cc b/gcc/pair-fusion.cc index b6643ca48123..602e572ab6c7 100644 --- a/gcc/pair-fusion.cc +++ b/gcc/pair-fusion.cc @@ -573,11 +573,13 @@ pair_fusion_bb_info::track_access (insn_info *insn, bool load_p, rtx mem) // If IGNORE_INSN is non-NULL, we should further ignore any hazards arising // from that insn. // -// N.B. we ignore any defs/uses of memory here as we deal with that separately, -// making use of alias disambiguation. +// IS_LOAD_STORE is true if INSN is one of the loads or stores in the +// candidate pair. We ignore any defs/uses of memory in such instructions +// as we deal with that separately, making use of alias disambiguation. static insn_info * latest_hazard_before (insn_info *insn, rtx *ignore, - insn_info *ignore_insn = nullptr) + insn_info *ignore_insn = nullptr, + bool is_load_store = true) { insn_info *result = nullptr; @@ -588,6 +590,10 @@ latest_hazard_before (insn_info *insn, rtx *ignore, && find_reg_note (insn->rtl (), REG_EH_REGION, NULL_RTX)) return insn->prev_nondebug_insn (); + if (!is_load_store + && accesses_include_memory (insn->defs ())) +return insn->prev_nondebug_insn (); + // Return true if we registered the hazard. auto hazard = [&](insn_info *h) -> bool { @@ -1238,7 +1244,7 @@ pair_fusion::find_trailing_add (insn_info *insns[2], insns[0]->uid (), insns[1]->uid ()); }; - insn_info *hazard = latest_hazard_before (cand, nullptr, insns[1]); + insn_info *hazard = latest_hazard_before (cand, nullptr, insns[1], false); if (!hazard || *hazard <= *pair_dst) { if (dump_file) @@ -1633,7 +1639,7 @@ pair_fusion_bb_info::fuse_pair (bool load_p, insn_info *insns[2] = { first, second }; auto_vec changes; - auto_vec tombstone_uids (2); + auto_vec tombstone_uids; rtx pats[2] = { PATTERN (first->rtl ()), @@ -1824,6 +1830,16 @@ pair_fusion_bb_info::fuse_pair (bool load_p, validate_change (rti, ®_NOTES (rti), reg_notes, true); }; + // Turn CHANGE into a memory definition tombstone. + auto make_tombstone = [&](insn_change *change) +{ + tombstone_uids.quick_push (change->insn ()->uid ()); + rtx_insn *rti = change->insn ()->rtl (); + validate_change (rti, &PATTERN (rti), gen_tombstone (), true); + validate_change (rti, ®_NOTES (rti), NULL_RTX, true); + change->new_uses = use_array (); +}; + if (load_p) { changes.safe_push (make_delete (first)); @@ -1879,11 +1895,7 @@ pair_fusion_bb_info::fuse_pair (bool load_p, } case Action::TOMBSTONE: { - tombstone_uids.quick_push (change->insn ()->uid ()); - rtx_insn *rti = change->insn ()->rtl (); - validate_change (rti, &PATTERN (rti), gen_tombstone (), true); - validate_change (rti, ®_NOTES (rti), NULL_RTX, true); - change->new_uses = use_array (nullptr, 0); +
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Factorisation set_descriptor_from_scalar conv_derived_to_class
https://gcc.gnu.org/g:5e24d81620f1bb17dfe5f1e920149635de39887c commit 5e24d81620f1bb17dfe5f1e920149635de39887c Author: Mikael Morin Date: Wed Jan 29 18:22:29 2025 +0100 Factorisation set_descriptor_from_scalar conv_derived_to_class Diff: --- gcc/fortran/trans-expr.cc | 42 +++--- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 6afb344245f2..091e1417faed 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -174,7 +174,8 @@ gfc_conv_null_array_descriptor (gfc_se *se, gfc_symbol *sym, gfc_expr *expr) void set_descriptor_from_scalar (stmtblock_t *block, tree desc, tree scalar, - gfc_expr *scalar_expr) + gfc_expr *scalar_expr, bool is_class, + tree cond_optional) { tree type = get_scalar_to_descriptor_type (scalar, gfc_expr_attr (scalar_expr)); @@ -185,9 +186,22 @@ set_descriptor_from_scalar (stmtblock_t *block, tree desc, tree scalar, tree dtype_ref = gfc_conv_descriptor_dtype (desc); gfc_add_modify (block, dtype_ref, dtype_val); - tree tmp = gfc_class_data_get (scalar); - if (!POINTER_TYPE_P (TREE_TYPE (tmp))) -tmp = gfc_build_addr_expr (NULL_TREE, tmp); + tree tmp; + if (is_class) +{ + tmp = gfc_class_data_get (scalar); + if (!POINTER_TYPE_P (TREE_TYPE (tmp))) + tmp = gfc_build_addr_expr (NULL_TREE, tmp); +} + else if (cond_optional) +{ + tmp = build3_loc (input_location, COND_EXPR, TREE_TYPE (scalar), + cond_optional, scalar, + fold_convert (TREE_TYPE (scalar), + null_pointer_node)); +} + else +tmp = scalar; gfc_conv_descriptor_data_set (block, desc, tmp); } @@ -1067,20 +1081,9 @@ gfc_conv_derived_to_class (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym, /* Scalar to an assumed-rank array. */ if (fsym->ts.u.derived->components->as) - { - tree type; - type = get_scalar_to_descriptor_type (parmse->expr, - gfc_expr_attr (e)); - gfc_add_modify (&parmse->pre, gfc_conv_descriptor_dtype (ctree), - gfc_get_dtype (type)); - if (optional) - parmse->expr = build3_loc (input_location, COND_EXPR, - TREE_TYPE (parmse->expr), - cond_optional, parmse->expr, - fold_convert (TREE_TYPE (parmse->expr), -null_pointer_node)); - gfc_conv_descriptor_data_set (&parmse->pre, ctree, parmse->expr); - } + set_descriptor_from_scalar (&parmse->pre, ctree, + parmse->expr, e, false, + cond_optional); else { tmp = fold_convert (TREE_TYPE (ctree), parmse->expr); @@ -1455,7 +1458,8 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts, && e->rank != class_ts.u.derived->components->as->rank) { if (e->rank == 0) - set_descriptor_from_scalar (&block, ctree, parmse->expr, e); + set_descriptor_from_scalar (&block, ctree, parmse->expr, e, + true, NULL_TREE); else gfc_class_array_data_assign (&block, ctree, parmse->expr, false); }
[gcc r15-7276] AVR: Allow to share libgcc's __negsi2.
https://gcc.gnu.org/g:eacb85eb24c381e38a76d3ad9b2d678c29c171f5 commit r15-7276-geacb85eb24c381e38a76d3ad9b2d678c29c171f5 Author: Georg-Johann Lay Date: Wed Jan 29 18:21:07 2025 +0100 AVR: Allow to share libgcc's __negsi2. libgcc has a module for __negsi2: REG_22:SI := - REG_22:SI. This patch adds a pattern that allows to share that function provided optimize_size. gcc/ * config/avr/avr.md (*negsi2.libgcc): New insn. Diff: --- gcc/config/avr/avr.md | 9 + 1 file changed, 9 insertions(+) diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index 1c956114a4b8..06e31aa7d72d 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -6299,6 +6299,15 @@ "" [(set_attr "isa" "*,*,mov,movw")]) +(define_insn "*negsi2.libgcc" + [(set (reg:SI REG_22) +(neg:SI (reg:SI REG_22))) + (clobber (reg:CC REG_CC))] + "reload_completed + && optimize_size" + "%~call __negsi2" + [(set_attr "type" "xcall")]) + (define_insn "*negsi2" [(set (match_operand:SI 0 "register_operand" "=!d,r,&r,&r") (neg:SI (match_operand:SI 1 "register_operand" "0,0,r ,r")))
[gcc r14-11261] Fortran: fix passing of component ref to assumed-rank dummy [PR118683]
https://gcc.gnu.org/g:b53d19a152cacfb4fcd1abb130d24a1c5dcaef15 commit r14-11261-gb53d19a152cacfb4fcd1abb130d24a1c5dcaef15 Author: Harald Anlauf Date: Tue Jan 28 21:21:40 2025 +0100 Fortran: fix passing of component ref to assumed-rank dummy [PR118683] While the fix for pr117774 addressed the passing of an inquiry reference to an assumed-rank dummy, it missed the similar case of passing a component reference. The newer testcase gfortran.dg/pr81978.f90 uncovered this latent issue with a UBSAN instrumented compiler. PR fortran/118683 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_procedure_call): The bounds update for passing to assumed-rank dummies shall also handle component references besides inquiry references. (cherry picked from commit 5d001fa122bf04cfd0611ff7723969a0421b3094) Diff: --- gcc/fortran/trans-expr.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 1efe435f397f..601cc546d438 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -7254,6 +7254,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, { if (ref->next->type == REF_INQUIRY) break; + if (ref->type == REF_ARRAY + && ref->u.ar.type != AR_ELEMENT) + break; }; if (ref->u.ar.type == AR_FULL && ref->u.ar.as->type != AS_ASSUMED_SIZE)