[gcc r15-648] nvptx: Correct pattern for popcountdi2 insn in nvptx.md.
https://gcc.gnu.org/g:1676ef6e91b902f592270e4bcf10b4fc342e200d commit r15-648-g1676ef6e91b902f592270e4bcf10b4fc342e200d Author: Roger Sayle Date: Sun May 19 09:49:45 2024 +0100 nvptx: Correct pattern for popcountdi2 insn in nvptx.md. The result of a POPCOUNT operation in RTL should have the same mode as its operand. This corrects the specification of popcount in the nvptx backend, splitting the current generic define_insn into two, one for popcountsi2 and the other for popcountdi2 (the latter with an explicit truncate). 2024-05-19 Roger Sayle gcc/ChangeLog * config/nvptx/nvptx.md (popcount2): Split into... (popcountsi2): define_insn handling SImode popcount. (popcountdi2): define_insn handling DImode popcount, with an explicit truncate:SI to produce an SImode result. Diff: --- gcc/config/nvptx/nvptx.md | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index 96e6c9116080..ef7e3fb00fac 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -655,11 +655,18 @@ DONE; }) -(define_insn "popcount2" +(define_insn "popcountsi2" [(set (match_operand:SI 0 "nvptx_register_operand" "=R") - (popcount:SI (match_operand:SDIM 1 "nvptx_register_operand" "R")))] + (popcount:SI (match_operand:SI 1 "nvptx_register_operand" "R")))] "" - "%.\\tpopc.b%T1\\t%0, %1;") + "%.\\tpopc.b32\\t%0, %1;") + +(define_insn "popcountdi2" + [(set (match_operand:SI 0 "nvptx_register_operand" "=R") + (truncate:SI + (popcount:DI (match_operand:DI 1 "nvptx_register_operand" "R"] + "" + "%.\\tpopc.b64\\t%0, %1;") ;; Multiplication variants
[gcc r15-649] Fix oversight in latest change to can_mult_highpart_p
https://gcc.gnu.org/g:3db8dd4139a7a5ce941684f1fc05ee0652e35544 commit r15-649-g3db8dd4139a7a5ce941684f1fc05ee0652e35544 Author: Eric Botcazou Date: Sun May 19 11:38:40 2024 +0200 Fix oversight in latest change to can_mult_highpart_p gcc/ * optabs-query.cc (can_mult_highpart_p): Test for the existence of a wider mode instead of requiring it. Diff: --- gcc/optabs-query.cc | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gcc/optabs-query.cc b/gcc/optabs-query.cc index de145be7075f..5149de57468d 100644 --- a/gcc/optabs-query.cc +++ b/gcc/optabs-query.cc @@ -510,17 +510,16 @@ int can_mult_highpart_p (machine_mode mode, bool uns_p) { optab op; - scalar_int_mode int_mode; + scalar_int_mode int_mode, wider_mode; op = uns_p ? umul_highpart_optab : smul_highpart_optab; if (optab_handler (op, mode) != CODE_FOR_nothing) return 1; /* If the mode is integral, synth from widening or larger operations. */ - if (is_a (mode, &int_mode)) + if (is_a (mode, &int_mode) + && GET_MODE_WIDER_MODE (int_mode).exists (&wider_mode)) { - scalar_int_mode wider_mode = GET_MODE_WIDER_MODE (int_mode).require (); - op = uns_p ? umul_widen_optab : smul_widen_optab; if (convert_optab_handler (op, wider_mode, mode) != CODE_FOR_nothing) return 2;
[gcc r15-650] testsuite, darwin: Compile a test without unwind frames.
https://gcc.gnu.org/g:0aa709ff9d4ca2f9794c4072d81bb68d784dd86c commit r15-650-g0aa709ff9d4ca2f9794c4072d81bb68d784dd86c Author: Iain Sandoe Date: Sun May 5 14:13:37 2024 +0100 testsuite, darwin: Compile a test without unwind frames. In the current Darwin implementation, we do not use .cfi_ insns and emitted EH frames contain 'coalesced' section designations which interfere with the scan asm. gcc/testsuite/ChangeLog: * gcc.dg/darwin-weakimport-3.c: Suppress unwind frames. Signed-off-by: Iain Sandoe Diff: --- gcc/testsuite/gcc.dg/darwin-weakimport-3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/darwin-weakimport-3.c b/gcc/testsuite/gcc.dg/darwin-weakimport-3.c index a15b5b0e7cb9..7e83987bad5e 100644 --- a/gcc/testsuite/gcc.dg/darwin-weakimport-3.c +++ b/gcc/testsuite/gcc.dg/darwin-weakimport-3.c @@ -10,11 +10,12 @@ With modern linkers this is moot, since even weak symbols are emitted into the regular sections. - To avoid the unwind tables -fno-asynchronous-unwind-tables. + To avoid the unwind tables -fno-asynchronous-unwind-tables + and fno-unwind-tables (since EH contains coalesced data). To ensure that we emit code for an older linker -mtarget-linker To avoid the get_pc thunk optimise at least O1. */ -/* { dg-options "-fno-asynchronous-unwind-tables -O1 -mtarget-linker 85.2" } */ +/* { dg-options "-fno-asynchronous-unwind-tables -fno-unwind-tables -O1 -mtarget-linker 85.2" } */ /* { dg-require-weak "" } */ /* { dg-final { scan-assembler-not "coalesced" } } */
[gcc r15-651] testsuite, C++, Darwin: Skip cxa_atexit-6, which is not applicable.
https://gcc.gnu.org/g:1073469074ff132478ec8d923ed8635c672f7d9b commit r15-651-g1073469074ff132478ec8d923ed8635c672f7d9b Author: Iain Sandoe Date: Sat May 11 09:24:33 2024 +0100 testsuite, C++, Darwin: Skip cxa_atexit-6, which is not applicable. For Darwin, non-weak functions defined in a TU always bind locally and so cxa_atexit-6.C is not applicable here. PR testsuite/114982 gcc/testsuite/ChangeLog: * g++.dg/tree-ssa/cxa_atexit-6.C: Skip for Darwin. Signed-off-by: Iain Sandoe Diff: --- gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C b/gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C index f6599a3c9f45..e22036067dd4 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C +++ b/gcc/testsuite/g++.dg/tree-ssa/cxa_atexit-6.C @@ -2,10 +2,14 @@ /* { dg-require-effective-target fpic } */ /* { dg-options "-O2 -fdump-tree-cddce1-details -fdump-tree-optimized -fPIC" } */ // { dg-require-effective-target cxa_atexit } +/* This test is not appropriate for targets where non-weak functions defined + in the TU always bind locally; see PR114982. */ +/* { dg-skip-if "PR114982" { *-*-darwin* } } */ /* PR tree-optimization/19661 */ /* The call to axexit should not be removed as A::~A() cannot be figured if it - is a pure/const function call as the function call g does not bind locally. */ + is a pure/const function call for platforms where the function call g does + not bind locally. */ __attribute__((noinline)) void g() {}
[gcc r15-652] [to-be-committed][RISC-V][PR target/115142] Do not create invalidate shift-add insn
https://gcc.gnu.org/g:e1ce9c37ed68136a99d44c8301990c184ba41849 commit r15-652-ge1ce9c37ed68136a99d44c8301990c184ba41849 Author: Jeff Law Date: Sun May 19 09:56:16 2024 -0600 [to-be-committed][RISC-V][PR target/115142] Do not create invalidate shift-add insn The circumstances which triggered this weren't something that should appear in the wild (-ftree-ter, without optimization enabled). So I wasn't planning to backport. Obviously if it shows up in another context we can revisit that decision. I've run this through my rv32gcv and rv64gc tester. Waiting on the CI system before committing. PR target/115142 gcc/ * config/riscv/riscv.cc (mem_shadd_or_shadd_rtx_p): Make sure shifted argument is a register. gcc/testsuite * gcc.target/riscv/pr115142.c: New test. Diff: --- gcc/config/riscv/riscv.cc | 1 + gcc/testsuite/gcc.target/riscv/pr115142.c | 10 ++ 2 files changed, 11 insertions(+) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 7a34b4be873f..d0c22058b8c3 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -2465,6 +2465,7 @@ mem_shadd_or_shadd_rtx_p (rtx x) { return ((GET_CODE (x) == ASHIFT || GET_CODE (x) == MULT) + && register_operand (XEXP (x, 0), GET_MODE (x)) && CONST_INT_P (XEXP (x, 1)) && ((GET_CODE (x) == ASHIFT && IN_RANGE (INTVAL (XEXP (x, 1)), 1, 3)) || (GET_CODE (x) == MULT diff --git a/gcc/testsuite/gcc.target/riscv/pr115142.c b/gcc/testsuite/gcc.target/riscv/pr115142.c new file mode 100644 index ..40ba49dfa20b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr115142.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -ftree-ter" } */ + +long a; +char b; +void e() { + char f[8][1]; + b = f[a][a]; +} +
[gcc r15-655] DSE: Fix ICE after allow vector type in get_stored_val
https://gcc.gnu.org/g:88b3f83238087cbe2aa2c51c6054796856f2fb94 commit r15-655-g88b3f83238087cbe2aa2c51c6054796856f2fb94 Author: Pan Li Date: Tue Apr 30 09:42:39 2024 +0800 DSE: Fix ICE after allow vector type in get_stored_val We allowed vector type for get_stored_val when read is less than or equal to store in previous. Unfortunately, the valididate_subreg treats the vector type's size is less than vector register as invalid. Then we will have ICE here. This patch would like to fix it by filter-out the invalid type size, and make sure the subreg is valid for both the read_mode and store_mode before perform the real gen_lowpart. The below test suites are passed for this patch: * The x86 bootstrap test. * The x86 regression test. * The riscv rv64gcv regression test. * The riscv rv64gc regression test. * The aarch64 regression test. gcc/ChangeLog: * dse.cc (get_stored_val): Make sure read_mode/write_mode is valid subreg before gen_lowpart. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/bug-6.c: New test. Signed-off-by: Pan Li Diff: --- gcc/dse.cc | 4 +++- gcc/testsuite/gcc.target/riscv/rvv/base/bug-6.c | 22 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/dse.cc b/gcc/dse.cc index edc7a1dfecf7..1596da91da08 100644 --- a/gcc/dse.cc +++ b/gcc/dse.cc @@ -1946,7 +1946,9 @@ get_stored_val (store_info *store_info, machine_mode read_mode, copy_rtx (store_info->const_rhs)); else if (VECTOR_MODE_P (read_mode) && VECTOR_MODE_P (store_mode) && known_le (GET_MODE_BITSIZE (read_mode), GET_MODE_BITSIZE (store_mode)) -&& targetm.modes_tieable_p (read_mode, store_mode)) +&& targetm.modes_tieable_p (read_mode, store_mode) +&& validate_subreg (read_mode, store_mode, copy_rtx (store_info->rhs), + subreg_lowpart_offset (read_mode, store_mode))) read_reg = gen_lowpart (read_mode, copy_rtx (store_info->rhs)); else read_reg = extract_low_bits (read_mode, store_mode, diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/bug-6.c b/gcc/testsuite/gcc.target/riscv/rvv/base/bug-6.c new file mode 100644 index ..5bb00b8f587e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/bug-6.c @@ -0,0 +1,22 @@ +/* Test that we do not have ice when compile */ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize" } */ + +struct A { float x, y; }; +struct B { struct A u; }; + +extern void bar (struct A *); + +float +f3 (struct B *x, int y) +{ + struct A p = {1.0f, 2.0f}; + struct A *q = &x[y].u; + + __builtin_memcpy (&q->x, &p.x, sizeof (float)); + __builtin_memcpy (&q->y, &p.y, sizeof (float)); + + bar (&p); + + return x[y].u.x + x[y].u.y; +}
[gcc r15-657] Fortran: invoke.texi - link to OpenCoarrays.org + mention libcaf_single
https://gcc.gnu.org/g:544d5dcc9150c0ea278fba79ea515f5a87732ce7 commit r15-657-g544d5dcc9150c0ea278fba79ea515f5a87732ce7 Author: Tobias Burnus Date: Mon May 20 08:33:31 2024 +0200 Fortran: invoke.texi - link to OpenCoarrays.org + mention libcaf_single gcc/fortran/ChangeLog: * invoke.texi (fcoarray): Link to OpenCoarrays.org; mention libcaf_single. Diff: --- gcc/fortran/invoke.texi | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 40e8e4a7cdde..6bc42afe2c4f 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -1753,7 +1753,10 @@ Single-image mode, i.e. @code{num_images()} is always one. @item @samp{lib} Library-based coarray parallelization; a suitable GNU Fortran coarray -library needs to be linked. +library such as @url{http://opencoarrays.org} needs to be linked. +Alternatively, GCC's @code{libcaf_single} library can be linked, +albeit it only supports a single image. + @end table
[gcc r15-658] Fortran: Fix SHAPE for zero-size arrays
https://gcc.gnu.org/g:b701306a9b38bd74cdc26c7ece5add22f2203b56 commit r15-658-gb701306a9b38bd74cdc26c7ece5add22f2203b56 Author: Tobias Burnus Date: Mon May 20 08:34:48 2024 +0200 Fortran: Fix SHAPE for zero-size arrays PR fortran/115150 gcc/fortran/ChangeLog: * trans-intrinsic.cc (gfc_conv_intrinsic_bound): Fix SHAPE for zero-size arrays gcc/testsuite/ChangeLog: * gfortran.dg/shape_12.f90: New test. Diff: --- gcc/fortran/trans-intrinsic.cc | 4 ++- gcc/testsuite/gfortran.dg/shape_12.f90 | 51 ++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index 80dc3426ab04..912c1000e186 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -3090,7 +3090,9 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, enum gfc_isym_id op) lbound, gfc_index_one_node); } else if (op == GFC_ISYM_SHAPE) - se->expr = size; + se->expr = fold_build2_loc (input_location, MAX_EXPR, + gfc_array_index_type, size, + gfc_index_zero_node); else gcc_unreachable (); diff --git a/gcc/testsuite/gfortran.dg/shape_12.f90 b/gcc/testsuite/gfortran.dg/shape_12.f90 new file mode 100644 index ..e672e1ff9f95 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/shape_12.f90 @@ -0,0 +1,51 @@ +! { dg-do run } +! +! PR fortran/115150 +! +! Check that SHAPE handles zero-sized arrays correctly +! +implicit none +call one +call two + +contains + +subroutine one + real,allocatable :: A(:),B(:,:) + allocate(a(3:0), b(5:1, 2:5)) + + if (any (shape(a) /= [0])) stop 1 + if (any (shape(b) /= [0, 4])) stop 2 + if (size(a) /= 0) stop 3 + if (size(b) /= 0) stop 4 + if (any (lbound(a) /= [1])) stop 5 + if (any (lbound(b) /= [1, 2])) stop 6 + if (any (ubound(a) /= [0])) stop 5 + if (any (ubound(b) /= [0,5])) stop 6 +end + +subroutine two +integer :: x1(10), x2(10,10) +call f(x1, x2, -3) +end + +subroutine f(y1, y2, n) + integer, value :: n + integer :: y1(1:n) + integer :: y2(1:n,4,2:*) + call g(y1, y2) +end + +subroutine g(z1, z2) + integer :: z1(..), z2(..) + + if (any (shape(z1) /= [0])) stop 1 + if (any (shape(z2) /= [0, 4, -1])) stop 2 + if (size(z1) /= 0) stop 3 + if (size(z2) /= 0) stop 4 + if (any (lbound(z1) /= [1])) stop 5 + if (any (lbound(z2) /= [1, 1, 1])) stop 6 + if (any (ubound(z1) /= [0])) stop 5 + if (any (ubound(z2) /= [0, 4, -1])) stop 6 +end +end