]> gcc.gnu.org Git - gcc.git/log
gcc.git
5 weeks agoBefore running fast VRP, make sure all edges have EXECUTABLE set.
Andrew MacLeod [Fri, 6 Sep 2024 15:42:14 +0000 (11:42 -0400)]
Before running fast VRP, make sure all edges have EXECUTABLE set.

PR tree-optimization/116588
gcc/
* tree-vrp.cc (execute_fast_vrp): Start with all edges executable.
gcc/testsuite/
* gcc.dg/pr116588.c: New.

5 weeks ago[PATCH] RISC-V: Add missing insn types for XiangShan Nanhu scheduler model
Zhao Dingyi [Sat, 7 Sep 2024 16:48:46 +0000 (10:48 -0600)]
[PATCH] RISC-V: Add missing insn types for XiangShan Nanhu scheduler model

This patch aims to add the missing instruction types to the XiangShan-Nanhu scheduler model.

The current XiangShan -Nanhu model lacks the trap, atomic trap, fcvt_i2f, and fcvt_f2i instructions.

The trap, atomic, and i2f instructions belong to xs_jmp_rs. [1]

The f2i instruction belongs to xs_fmisc_rs.[2]

[1]
https://github.com/OpenXiangShan/XiangShan/blob/v2.0/src/main/scala/xiangshan/package.scala#L780

[2]
https://github.com/OpenXiangShan/XiangShan/blob/v2.0/src/main/scala/xiangshan/backend/decode/DecodeUnit.scala#L290

gcc/ChangeLog:

* config/riscv/xiangshan.md: Add atomic, trap, fcvt_i2f, fcvt_f2i.

5 weeks ago[PATCH v4] [target/116592] RISC-V: Fix illegal operands "th.vsetvli zero,0,e32,m8...
Jin Ma [Sat, 7 Sep 2024 16:29:02 +0000 (10:29 -0600)]
[PATCH v4] [target/116592] RISC-V: Fix illegal operands "th.vsetvli zero,0,e32,m8" for XTheadVector

Since the THeadVector vsetvli does not support vl as an immediate, we
need to convert 0 to zero when outputting asm.

PR target/116592

gcc/ChangeLog:

* config/riscv/thead.cc (th_asm_output_opcode): Change '0' to
"zero"

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/xtheadvector/pr116592.c: New test.

5 weeks agoImplement first part of unsigned integers for Fortran.
Thomas Koenig [Sat, 7 Sep 2024 14:59:46 +0000 (16:59 +0200)]
Implement first part of unsigned integers for Fortran.

gcc/fortran/ChangeLog:

* arith.cc (gfc_reduce_unsigned): New function.
(gfc_arith_error): Add ARITH_UNSIGNED_TRUNCATED and
ARITH_UNSIGNED_NEGATIVE.
(gfc_arith_init_1): Initialize unsigned types.
(gfc_check_unsigned_range): New function.
(gfc_range_check): Handle unsigned types.
(gfc_arith_uminus): Likewise.
(gfc_arith_plus): Likewise.
(gfc_arith_minus): Likewise.
(gfc_arith_times): Likewise.
(gfc_arith_divide): Likewise.
(gfc_compare_expr): Likewise.
(eval_intrinsic): Likewise.
(gfc_int2int): Also convert unsigned.
(gfc_uint2uint): New function.
(gfc_int2uint): New function.
(gfc_uint2int): New function.
(gfc_uint2real): New function.
(gfc_uint2complex): New function.
(gfc_real2uint): New function.
(gfc_complex2uint): New function.
(gfc_log2uint): New function.
(gfc_uint2log): New function.
* arith.h (gfc_int2uint, gfc_uint2uint, gfc_uint2int, gfc_uint2real):
Add prototypes.
(gfc_uint2complex, gfc_real2uint, gfc_complex2uint, gfc_log2uint):
Likewise.
(gfc_uint2log): Likewise.
* check.cc (gfc_boz2uint): New function
(type_check2): New function.
(int_or_real_or_unsigned_check): New function.
(less_than_bitsizekind): Adjust for unsingeds.
(less_than_bitsize2): Likewise.
(gfc_check_allocated): Likewise.
(gfc_check_mod): Likewise.
(gfc_check_bge_bgt_ble_blt): Likewise.
(gfc_check_bitfcn): Likewise.
(gfc_check_digits): Likewise.
(gfc_check_dshift): Likewise.
(gfc_check_huge): Likewise.
(gfc_check_iu): New function.
(gfc_check_iand_ieor_ior): Adjust for unsigneds.
(gfc_check_ibits): Likewise.
(gfc_check_uint): New function.
(gfc_check_ishft): Adjust for unsigneds.
(gfc_check_ishftc): Likewise.
(gfc_check_min_max): Likewise.
(gfc_check_merge_bits): Likewise.
(gfc_check_selected_int_kind): Likewise.
(gfc_check_shift): Likewise.
(gfc_check_mvbits): Likewise.
(gfc_invalid_unsigned_ops): Likewise.
* decl.cc (gfc_match_decl_type_spec): Likewise.
* dump-parse-tree.cc (show_expr): Likewise.
* expr.cc (gfc_get_constant_expr): Likewise.
(gfc_copy_expr): Likewise.
(gfc_extract_int): Likewise.
(numeric_type): Likewise.
* gfortran.h (enum arith): Extend with ARITH_UNSIGNED_TRUNCATED
and ARITH_UNSIGNED_NEGATIVE.
(enum gfc_isym_id): Extend with GFC_ISYM_SU_KIND and GFC_ISYM_UINT.
(gfc_check_unsigned_range): New prototype-
(gfc_arith_error): Likewise.
(gfc_reduce_unsigned): Likewise.
(gfc_boz2uint): Likewise.
(gfc_invalid_unsigned_ops): Likewise.
(gfc_convert_mpz_to_unsigned): Likewise.
* gfortran.texi: Add some rudimentary documentation.
* intrinsic.cc (gfc_type_letter): Adjust for unsigneds.
(add_functions): Add uint and adjust functions to be called.
(add_conversions): Add unsigned conversions.
(gfc_convert_type_warn): Adjust for unsigned.
* intrinsic.h (gfc_check_iu, gfc_check_uint, gfc_check_mod, gfc_simplify_uint,
gfc_simplify_selected_unsigned_kind, gfc_resolve_uint): New prototypes.
* invoke.texi: Add -funsigned.
* iresolve.cc (gfc_resolve_dshift): Handle unsigneds.
(gfc_resolve_iand): Handle unsigneds.
(gfc_resolve_ibclr): Handle unsigneds.
(gfc_resolve_ibits): Handle unsigneds.
(gfc_resolve_ibset): Handle unsigneds.
(gfc_resolve_ieor): Handle unsigneds.
(gfc_resolve_ior): Handle unsigneds.
(gfc_resolve_uint): Handle unsigneds.
(gfc_resolve_merge_bits): Handle unsigneds.
(gfc_resolve_not): Handle unsigneds.
* lang.opt: Add -funsigned.
* libgfortran.h: Add BT_UNSIGNED.
* match.cc (gfc_match_type_spec): Match UNSIGNED.
* misc.cc (gfc_basic_typename): Add UNSIGNED.
(gfc_typename): Likewise.
* primary.cc (convert_unsigned): New function.
(match_unsigned_constant): New function.
(gfc_match_literal_constant): Handle unsigned.
* resolve.cc (resolve_operator): Handle unsigned.
(resolve_ordinary_assign): Likewise.
* simplify.cc (convert_mpz_to_unsigned): Renamed to...
(gfc_convert_mpz_to_unsigned): and adjusted.
(gfc_simplify_bit_size): Adjusted for unsigned.
(compare_bitwise): Likewise.
(gfc_simplify_bge): Likewise.
(gfc_simplify_bgt): Likewise.
(gfc_simplify_ble): Likewise.
(gfc_simplify_blt): Likewise.
(simplify_cmplx): Likewise.
(gfc_simplify_digits): Likewise.
(simplify_dshift): Likewise.
(gfc_simplify_huge): Likewise.
(gfc_simplify_iand): Likewise.
(gfc_simplify_ibclr): Likewise.
(gfc_simplify_ibits): Likewise.
(gfc_simplify_ibset): Likewise.
(gfc_simplify_ieor): Likewise.
(gfc_simplify_uint): Likewise.
(gfc_simplify_ior): Likewise.
(simplify_shift): Likewise.
(gfc_simplify_ishftc): Likewise.
(gfc_simplify_merge_bits): Likewise.
(min_max_choose): Likewise.
(gfc_simplify_mod): Likewise.
(gfc_simplify_modulo): Likewise.
(gfc_simplify_popcnt): Likewise.
(gfc_simplify_range): Likewise.
(gfc_simplify_selected_unsigned_kind): Likewise.
(gfc_convert_constant): Likewise.
* target-memory.cc (size_unsigned): New function.
(gfc_element_size): Adjust for unsigned.
* trans-const.h (gfc_conv_mpz_unsigned_to_tree): Add prototype.
* trans-const.cc (gfc_conv_mpz_unsigned_to_tree): Handle unsigneds.
(gfc_conv_constant_to_tree): Likewise.
* trans-decl.cc (gfc_conv_cfi_to_gfc): Put in "not yet implemented".
* trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Likewise.
* trans-stmt.cc (gfc_trans_integer_select): Handle unsigned.
(gfc_trans_select): Likewise.
* trans-intrinsic.cc (gfc_conv_intrinsic_mod): Handle unsigned.
(gfc_conv_intrinsic_shift): Likewise.
(gfc_conv_intrinsic_function): Add GFC_ISYM_UINT.
* trans-io.cc (enum iocall): Add IOCALL_X_UNSIGNED and IOCALL_X_UNSIGNED_WRITE.
(gfc_build_io_library_fndecls): Add transfer_unsigned and transfer_unsigned_write.
(transfer_expr): Handle unsigneds.
* trans-types.cc (gfc_unsinged_kinds): New array.
(gfc_unsigned_types): Likewise.
(gfc_init_kinds): Handle them.
(validate_unsigned): New function.
(gfc_validate_kind): Use it.
(gfc_build_unsigned_type): New function.
(gfc_init_types): Use it.
(gfc_get_unsigned_type): New function.
(gfc_typenode_for_spec): Handle unsigned.
* trans-types.h (gfc_get_unsigned_type): New prototype.

libgfortran/ChangeLog:

* gfortran.map: Add _gfortran_transfer_unsgned and
_gfortran_transfer-signed.
* io/io.h (set_unsigned): New prototype.
(us_max): New prototype.
(read_decimal_unsigned): New prototype.
(write_iu): New prototype.
* io/list_read.c (convert_unsigned): New function.
(read_integer): Also handle unsigneds.
(list_formatted_read_scalar): Handle unsigneds.
(nml_read_obj): Likewise.
* io/read.c (set_unsigned): New function.
(us_max): New function.
(read_utf8): Whitespace fixes.
(read_default_char1): Whitespace fixes.
(read_a_char4): Whitespace fixes.
(next_char): Whiltespace fixes.
(read_decimal_unsigned): New function.
(read_f): Whitespace fixes.
(read_x): Whitespace fixes.
* io/transfer.c (transfer_unsigned): New function.
(transfer_unsigned_write): New function.
(require_one_of_two_types): New function.
(formatted_transfer_scalar_read): Use it.
(formatted_transfer_scalar_write): Also use it.
* io/write.c (write_decimal_unsigned): New function.
(write_iu): New function.
(write_unsigned): New function.
(list_formatted_write_scalar): Adjust for unsigneds.
* libgfortran.h (GFC_UINTEGER_1_HUGE): Define.
(GFC_UINTEGER_2_HUGE): Define.
(GFC_UINTEGER_4_HUGE): Define.
(GFC_UINTEGER_8_HUGE): Define.
(GFC_UINTEGER_16_HUGE): Define.
(HAVE_GFC_UINTEGER_1): Undefine (done by mk-kind-h.sh)
(HAVE_GFC_UINTEGER_4): Likewise.
* mk-kinds-h.sh: Add GFC_UINTEGER_*_HUGE.

gcc/testsuite/ChangeLog:

* gfortran.dg/unsigned_1.f90: New test.
* gfortran.dg/unsigned_10.f90: New test.
* gfortran.dg/unsigned_11.f90: New test.
* gfortran.dg/unsigned_12.f90: New test.
* gfortran.dg/unsigned_13.f90: New test.
* gfortran.dg/unsigned_14.f90: New test.
* gfortran.dg/unsigned_15.f90: New test.
* gfortran.dg/unsigned_16.f90: New test.
* gfortran.dg/unsigned_17.f90: New test.
* gfortran.dg/unsigned_18.f90: New test.
* gfortran.dg/unsigned_19.f90: New test.
* gfortran.dg/unsigned_2.f90: New test.
* gfortran.dg/unsigned_20.f90: New test.
* gfortran.dg/unsigned_21.f90: New test.
* gfortran.dg/unsigned_22.f90: New test.
* gfortran.dg/unsigned_23.f90: New test.
* gfortran.dg/unsigned_24.f: New test.
* gfortran.dg/unsigned_3.f90: New test.
* gfortran.dg/unsigned_4.f90: New test.
* gfortran.dg/unsigned_5.f90: New test.
* gfortran.dg/unsigned_6.f90: New test.
* gfortran.dg/unsigned_7.f90: New test.
* gfortran.dg/unsigned_8.f90: New test.
* gfortran.dg/unsigned_9.f90: New test.

5 weeks agolibiberty: Fix up > 64K section handling in simple_object_elf_copy_lto_debug_section...
Jakub Jelinek [Sat, 7 Sep 2024 07:36:53 +0000 (09:36 +0200)]
libiberty: Fix up > 64K section handling in simple_object_elf_copy_lto_debug_section [PR116614]

cat abc.C
  #define A(n) struct T##n {} t##n;
  #define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) A(n##8) A(n##9)
  #define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) B(n##8) B(n##9)
  #define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7) C(n##8) C(n##9)
  #define E(n) D(n##0) D(n##1) D(n##2) D(n##3) D(n##4) D(n##5) D(n##6) D(n##7) D(n##8) D(n##9)
  E(1) E(2) E(3)
  int main () { return 0; }
./xg++ -B ./ -o abc{.o,.C} -flto -flto-partition=1to1 -O2 -g -fdebug-types-section -c
./xgcc -B ./ -o abc{,.o} -flto -flto-partition=1to1 -O2
(not included in testsuite as it takes a while to compile) FAILs with
lto-wrapper: fatal error: Too many copied sections: Operation not supported
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

The following patch fixes that.  Most of the 64K+ section support for
reading and writing was already there years ago (and especially reading used
quite often already) and a further bug fixed in it in the PR104617 fix.

Yet, the fix isn't solely about removing the
  if (new_i - 1 >= SHN_LORESERVE)
    {
      *err = ENOTSUP;
      return "Too many copied sections";
    }
5 lines, the missing part was that the function only handled reading of
the .symtab_shndx section but not copying/updating of it.
If the result has less than 64K-epsilon sections, that actually wasn't
needed, but e.g. with -fdebug-types-section one can exceed that pretty
easily (reported to us on WebKitGtk build on ppc64le).
Updating the section is slightly more complicated, because it basically
needs to be done in lock step with updating the .symtab section, if one
doesn't need to use SHN_XINDEX in there, the section should (or should be
updated to) contain SHN_UNDEF entry, otherwise needs to have whatever would
be overwise stored but couldn't fit.  But repeating due to that all the
symtab decisions what to discard and how to rewrite it would be ugly.

So, the patch instead emits the .symtab_shndx section (or sections) last
and prepares the content during the .symtab processing and in a second
pass when going just through .symtab_shndx sections just uses the saved
content.

2024-09-07  Jakub Jelinek  <jakub@redhat.com>

PR lto/116614
* simple-object-elf.c (SHN_COMMON): Align comment with neighbouring
comments.
(SHN_HIRESERVE): Use uppercase hex digits instead of lowercase for
consistency.
(simple_object_elf_find_sections): Formatting fixes.
(simple_object_elf_fetch_attributes): Likewise.
(simple_object_elf_attributes_merge): Likewise.
(simple_object_elf_start_write): Likewise.
(simple_object_elf_write_ehdr): Likewise.
(simple_object_elf_write_shdr): Likewise.
(simple_object_elf_write_to_file): Likewise.
(simple_object_elf_copy_lto_debug_section): Likewise.  Don't fail for
new_i - 1 >= SHN_LORESERVE, instead arrange in that case to copy
over .symtab_shndx sections, though emit those last and compute their
section content when processing associated .symtab sections.  Handle
simple_object_internal_read failure even in the .symtab_shndx reading
case.

5 weeks agoDaily bump.
GCC Administrator [Sat, 7 Sep 2024 00:17:53 +0000 (00:17 +0000)]
Daily bump.

5 weeks agolibstdc++: Fix std::chrono::parse for TAI and GPS clocks
Jonathan Wakely [Wed, 4 Sep 2024 20:23:20 +0000 (21:23 +0100)]
libstdc++: Fix std::chrono::parse for TAI and GPS clocks

Howard Hinnant brought to my attention that chrono::parse was giving
incorrect values for chrono::gps_clock, because it was applying the
offset between the GPS clock and UTC. That's incorrect, because when we
parse HH::MM::SS as a GPS time, the result should be that time, not
HH:MM:SS+offset.

The problem was that I was using clock_cast to convert from sys_time to
utc_time and then using clock_time again to convert to gps_time. The
solution is to convert the parsed time into an duration representing the
time since the GPS clock's epoch, then construct a gps_time directly
from that duration.

As well as adding tests for correct round tripping of times for all
clocks, this also adds some more tests for correct results with
std::format.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (from_stream): Fix conversions in
overloads for gps_time and tai_time.
* testsuite/std/time/clock/file/io.cc: Test round tripping using
chrono::parse. Add additional std::format tests.
* testsuite/std/time/clock/gps/io.cc: Likewise.
* testsuite/std/time/clock/local/io.cc: Likewise.
* testsuite/std/time/clock/tai/io.cc: Likewise.
* testsuite/std/time/clock/utc/io.cc: Likewise.

5 weeks agoc++: adjust testcase to reveal failure [PR107919]
Jason Merrill [Fri, 6 Sep 2024 19:14:33 +0000 (15:14 -0400)]
c++: adjust testcase to reveal failure [PR107919]

This test appeared to be passing, but only because the warning was
suppressed by #pragma system_header.

PR tree-optimization/107919

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wuninitialized-pr107919-1.C: Add -Wsystem-headers and
xfail.

5 weeks agolibstdc++: add missing __
Jason Merrill [Fri, 6 Sep 2024 16:12:24 +0000 (12:12 -0400)]
libstdc++: add missing __

I forgot the __ in my recent r15-3500-g1914ca8791ce4e.

libstdc++-v3/ChangeLog:

* include/bits/regex_constants.h: Add __ to attribute.

5 weeks agoUpdate gcc uk.po
Joseph Myers [Fri, 6 Sep 2024 16:13:40 +0000 (16:13 +0000)]
Update gcc uk.po

* uk.po: Update.

5 weeks agors6000,extend and document built-ins vec_test_lsbb_all_ones and vec_test_lsbb_all_zeros
Carl Love [Fri, 6 Sep 2024 16:06:34 +0000 (12:06 -0400)]
rs6000,extend and document built-ins vec_test_lsbb_all_ones and vec_test_lsbb_all_zeros

The built-ins currently support vector unsigned char arguments.  Extend the
built-ins to also support vector signed char and vector bool char
arguments.

Add documentation for the Power 10 built-ins vec_test_lsbb_all_ones
and vec_test_lsbb_all_zeros.  The vec_test_lsbb_all_ones built-in
returns 1 if the least significant bit in each byte is a 1, returns
0 otherwise.  Similarly, vec_test_lsbb_all_zeros returns a 1 if
the least significant bit in each byte is a zero and 0 otherwise.

Add addtional test cases for the built-ins in files:
  gcc/testsuite/gcc.target/powerpc/lsbb.c
  gcc/testsuite/gcc.target/powerpc/lsbb-runnable.c

gcc/ChangeLog:
* config/rs6000/rs6000-overload.def (vec_test_lsbb_all_ones,
vec_test_lsbb_all_zeros): Add built-in instances for vector signed
char and vector bool char.
* doc/extend.texi (vec_test_lsbb_all_ones,
vec_test_lsbb_all_zeros): Add documentation for the
existing built-ins.

gcc/testsuite/ChangeLog:gcc/testsuite/ChangeLog:
* gcc.target/powerpc/lsbb-runnable.c: Add test cases for the vector
signed char and vector bool char instances of
vec_test_lsbb_all_zeros and vec_test_lsbb_all_ones built-ins.
* gcc.target/powerpc/lsbb.c: Add compile test cases for the vector
signed char and vector bool char instances of
vec_test_lsbb_all_zeros and vec_test_lsbb_all_ones built-ins.

5 weeks agomiddle-end: check that the lhs of a COND_EXPR is an SSA_NAME in cond_store recognitio...
Tamar Christina [Fri, 6 Sep 2024 13:05:43 +0000 (14:05 +0100)]
middle-end: check that the lhs of a COND_EXPR is an SSA_NAME in cond_store recognition [PR116628]

Because the vect_recog_bool_pattern can at the moment still transition
out of GIMPLE and back into GENERIC the vect_recog_cond_store_pattern can
end up using an expression as a mask rather than an SSA_NAME.

This adds an explicit check that we have a mask and not an expression.

gcc/ChangeLog:

PR tree-optimization/116628
* tree-vect-patterns.cc (vect_recog_cond_store_pattern): Add SSA_NAME
check on expression.

gcc/testsuite/ChangeLog:

PR tree-optimization/116628
* gcc.dg/vect/pr116628.c: New test.

5 weeks agoaarch64: Use is_attribute_namespace_p and get_attribute_name inside aarch64_lookup_sh...
Andrew Pinski [Wed, 4 Sep 2024 16:06:53 +0000 (09:06 -0700)]
aarch64: Use is_attribute_namespace_p and get_attribute_name inside aarch64_lookup_shared_state_flags [PR116598]

The code in aarch64_lookup_shared_state_flags all C++11 attributes on the function type
had a namespace associated with them. But with the addition of reproducible/unsequenced,
this is not true.

This fixes the issue by using is_attribute_namespace_p instead of manually figuring out
the namespace is named "arm" and uses get_attribute_name instead of manually grabbing
the attribute name.

Built and tested for aarch64-linux-gnu.

gcc/ChangeLog:

PR target/116598
* config/aarch64/aarch64.cc (aarch64_lookup_shared_state_flags): Use
is_attribute_namespace_p and get_attribute_name instead of manually grabbing
the namespace and name of the attribute.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
5 weeks agoipa: Move pass_ipa_cdtor_merge before pass_ipa_cp and pass_ipa_sra
Martin Jambor [Fri, 6 Sep 2024 12:12:54 +0000 (14:12 +0200)]
ipa: Move pass_ipa_cdtor_merge before pass_ipa_cp and pass_ipa_sra

When looking at PR 115815 we realized that it would make sense to make
calls to functions originally declared static constructors and
destructors created by pass_ipa_cdtor_merge visible to IPA-SRA.  This
patch does that.

gcc/ChangeLog:

2024-07-25  Martin Jambor  <mjambor@suse.cz>

* passes.def: Move pass_ipa_cdtor_merge before pass_ipa_cp and
pass_ipa_sra.

5 weeks agoipa: Treat static constructors and destructors as non-local (PR 115815)
Martin Jambor [Fri, 6 Sep 2024 12:12:53 +0000 (14:12 +0200)]
ipa: Treat static constructors and destructors as non-local (PR 115815)

In PR 115815, IPA-SRA thought it had control over all invocations of a
(recursive) static destructor but it did not see the implied
invocation which led to the original being left behind and the
clean-up code encountering uses of SSAs that definitely should have
been dead.

Fixed by teaching cgraph_node::can_be_local_p about static
constructors and destructors.  Similar test is missing in
cgraph_node::local_p so I added the check there as well.

gcc/ChangeLog:

2024-07-25  Martin Jambor  <mjambor@suse.cz>

PR ipa/115815
* cgraph.cc (cgraph_node_cannot_be_local_p_1): Also check
DECL_STATIC_CONSTRUCTOR and DECL_STATIC_DESTRUCTOR.
* ipa-visibility.cc (non_local_p): Likewise.
(cgraph_node::local_p): Delete extraneous line of tabs.

gcc/testsuite/ChangeLog:

2024-07-25  Martin Jambor  <mjambor@suse.cz>

PR ipa/115815
* gcc.dg/lto/pr115815_0.c: New test.

5 weeks agoFix SLP double-reduction support
Richard Biener [Fri, 6 Sep 2024 11:24:38 +0000 (13:24 +0200)]
Fix SLP double-reduction support

When doing SLP discovery I forgot to handle double reductions even
though they are already queued in LOOP_VINFO_REDUCTIONS.

* tree-vect-slp.cc (vect_analyze_slp): Also handle discovery
for double reductions.

5 weeks agoc++: Partially implement CWG 2867 - Order of initialization for structured bindings...
Jakub Jelinek [Fri, 6 Sep 2024 11:50:47 +0000 (13:50 +0200)]
c++: Partially implement CWG 2867 - Order of initialization for structured bindings [PR115769]

The following patch partially implements CWG 2867
- Order of initialization for structured bindings.
The DR requires that initialization of e is sequenced before r_i and
that r_i initialization is sequenced before r_j for j > i, we already do it
that way, the former ordering is a necessity so that the get calls are
actually emitted on already initialized variable, the rest just because
we implemented it that way, by going through the structured binding
vars in ascending order and doing their initialization.

The hard part not implemented yet is the lifetime extension of the
temporaries from the e initialization to after the get calls (if any).
Unlike the range-for lifetime extension patch which I've posted recently
where IMO we can just ignore lifetime extension of reference bound
temporaries because all the temporaries are extended to the same spot,
here lifetime extension of reference bound temporaries should last until
the end of lifetime of e, while other temporaries only after all the get
calls.

The patch just attempts to deal with automatic structured bindings for now,
I'll post a patch for static locals incrementally and I don't have a patch
for namespace scope structured bindings yet, this patch should just keep
existing behavior for both static locals and namespace scope structured
bindings.

What GCC currently emits is a CLEANUP_POINT_EXPR around the e
initialization, followed optionally by nested CLEANUP_STMTs for cleanups
like the e dtor if any and dtors of lifetime extended temporaries from
reference binding; inside of the CLEANUP_STMT CLEANUP_BODY then the
initialization of the individual variables for the tuple case, again with
optional CLEANUP_STMT if e.g. lifetime extended temporaries from reference
binding are needed in those.

The following patch drops that first CLEANUP_POINT_EXPR and instead
wraps the whole sequence of the e initialization and the individual variable
initialization with get calls after it into a single CLEANUP_POINT_EXPR.
If there are any CLEANUP_STMTs needed, they are all emitted first, with
the CLEANUP_POINT_EXPR for e initialization and the individual variable
initialization inside of those, and a guard variable set after different
phases in those expressions guarding the corresponding cleanups, so that
they aren't invoked until the respective variables are constructed.
This is implemented by cp_finish_decl doing cp_finish_decomp on its own
when !processing_template_decl (otherwise we often don't cp_finish_decl
or process it at a different time from when we want to call
cp_finish_decomp) or unless the decl is erroneous (cp_finish_decl has
too many early returns for erroneous cases, and for those we can actually
call it even multiple times, for the non-erroneous cases
non-processing_template_decl cases we need to call it just once).

The two testcases try to construct various temporaries and variables and
verify the order in which the temporaries and variables are constructed and
destructed.

2024-09-06  Jakub Jelinek  <jakub@redhat.com>

PR c++/115769
* cp-tree.h: Partially implement CWG 2867 - Order of initialization
for structured bindings.
(cp_finish_decomp): Add TEST_P argument defaulted to false.
* decl.cc (initialize_local_var): Add DECOMP argument, if true,
don't build cleanup and temporarily override stmts_are_full_exprs_p
to 0 rather than 1.  Formatting fix.
(cp_finish_decl): Invoke cp_finish_decomp for structured bindings
here, first with test_p.  For automatic structured binding bases
if the test cp_finish_decomp returned true wrap the initialization
together with what non-test cp_finish_decomp emits with a
CLEANUP_POINT_EXPR, and if there are any CLEANUP_STMTs needed, emit
them around the whole CLEANUP_POINT_EXPR with guard variables for the
cleanups.  Call cp_finish_decomp using RAII if not called with
decomp != NULL otherwise.
(cp_finish_decomp): Add TEST_P argument, change return type from
void to bool, if TEST_P is true, return true instead of emitting
actual code for the tuple case, otherwise return false.
* parser.cc (cp_convert_range_for): Don't call cp_finish_decomp
after cp_finish_decl.
(cp_parser_decomposition_declaration): Set DECL_DECOMP_BASE
before cp_finish_decl call.  Don't call cp_finish_decomp after
cp_finish_decl.
(cp_finish_omp_range_for): Don't call cp_finish_decomp after
cp_finish_decl.
* pt.cc (tsubst_stmt): Likewise.

* g++.dg/DRs/dr2867-1.C: New test.
* g++.dg/DRs/dr2867-2.C: New test.

5 weeks agoAVR: lra/116321 - Add test case.
Georg-Johann Lay [Fri, 6 Sep 2024 11:47:12 +0000 (13:47 +0200)]
AVR: lra/116321 - Add test case.

PR rtl-optimization/116321
gcc/testsuite/
* gcc.target/avr/torture/lra-pr116321.c: New test.

5 weeks agolibstdc++: avoid __GLIBCXX__ redefinition
Jason Merrill [Tue, 27 Aug 2024 17:15:38 +0000 (13:15 -0400)]
libstdc++: avoid __GLIBCXX__ redefinition

testsuite/lib/dg-options.exp defines __GLIBCXX__ to 9999999; avoid a macro
redefinition warning in that case.

libstdc++-v3/ChangeLog:

* include/bits/c++config: Avoid redefining __GLIBCXX__.

5 weeks agoFortran: Add OpenMP 'interop' directive parsing support
Tobias Burnus [Fri, 6 Sep 2024 09:45:46 +0000 (11:45 +0200)]
Fortran: Add OpenMP 'interop' directive parsing support

Parse OpenMP's 'interop' directive but stop with a 'sorry, unimplemented'
after resolving.

Additionally, it moves some clause dumping away from the end directive as
that lead to 'nowait' not being printed when it should as some cases were
missed.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_omp_namelist): Handle OMP_LIST_INIT.
(show_omp_clauses): Handle OMP_LIST_{INIT,USE,DESTORY}; move 'nowait'
from end-directive to the directive dump.
(show_omp_node, show_code_node): Handle EXEC_OMP_INTEROP.
* gfortran.h (enum gfc_statement): Add ST_OMP_INTEROP.
(OMP_LIST_INIT, OMP_LIST_USE, OMP_LIST_DESTROY): Add.
(enum gfc_exec_op): Add EXEC_OMP_INTEROP.
(struct gfc_omp_namelist): Add interop items to union.
(gfc_free_omp_namelist): Add boolean arg.
* match.cc (gfc_free_omp_namelist): Update to free
interop union members.
* match.h (gfc_match_omp_interop): New.
* openmp.cc (gfc_omp_directives): Uncomment 'interop' entry.
(gfc_free_omp_clauses, gfc_match_omp_allocate,
gfc_match_omp_flush, gfc_match_omp_clause_reduction): Update
call.
(enum omp_mask2): Add OMP_CLAUSE_{INIT,USE,DESTROY}.
(OMP_INTEROP_CLAUSES): Use it.
(gfc_match_omp_clauses): Match those clauses.
(gfc_match_omp_prefer_type, gfc_match_omp_init,
gfc_match_omp_interop): New.
(resolve_omp_clauses): Handle interop clauses.
(omp_code_to_statement): Add ST_OMP_INTEROP.
(gfc_resolve_omp_directive): Add EXEC_OMP_INTEROP.
* parse.cc (decode_omp_directive): Parse 'interop' directive.
(next_statement, gfc_ascii_statement): Handle ST_OMP_INTEROP.
* st.cc (gfc_free_statement): Likewise
* resolve.cc (gfc_resolve_code): Handle EXEC_OMP_INTEROP.
* trans.cc (trans_code): Likewise.
* trans-openmp.cc (gfc_trans_omp_directive): Print 'sorry'
for EXEC_OMP_INTEROP.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/interop-1.f90: New test.
* gfortran.dg/gomp/interop-2.f90: New test.
* gfortran.dg/gomp/interop-3.f90: New test.

5 weeks agoHandle non-grouped stores as single-lane SLP
Richard Biener [Fri, 29 Sep 2023 10:54:17 +0000 (12:54 +0200)]
Handle non-grouped stores as single-lane SLP

The following enables single-lane loop SLP discovery for non-grouped stores
and adjusts vectorizable_store to properly handle those.

For gfortran.dg/vect/vect-8.f90 we vectorize one additional loop,
not running into the "not falling back to strided accesses" bail-out.
I have not investigated in detail.

There is a set of i386 target assembler test FAILs,
gcc.target/i386/pr88531-2[bc].c in particular fail because the
target cannot identify SLP emulated gathers, see another mail from me.
Others need adjustment, I've adjusted one with this patch only.
In particular there are gcc.target/i386/cond_op_fma_*-1.c FAILs
that are because we no longer fold a VEC_COND_EXPR during the
region value-numbering we do after vectorization since we
code-generate a { 0.0, ... } constant in the VEC_COND_EXPR now
instead of having a separate statement which gets forwarded
and then triggers folding.  This leads to sligtly different
code generation.  The solution is probably to use gimple_build
when building stmts or, in this case, directly emit .COND_FMA
instead of .FMA and a VEC_COND_EXPR.

gcc.dg/vect/slp-19a.c mixes contiguous 8-lane SLP with a single
lane contiguous store from one lane of the 8-lane load and we
expect to use load-lanes for this reason but the heuristic for
forcing single-lane rediscovery as implemented doesn't trigger
here as it treats both SLP instances separately.  FAILs on RISC-V

gcc.dg/vect/slp-19c.c shows we fail to implement an interleaving
scheme for group_size 12 (by extension using the group_size 3
scheme to reduce to 4 lanes and then continue with a pow2 scheme
would work);  we are also not considering load-lanes because of
the above reason, but aarch64 cannot do ld12.  FAILs on AARCH64
(load requires three vectors) and x86_64.

gcc.dg/vect/slp-19c.c FAILs with variable-length vectors because
of "SLP induction not supported for variable-length vectors".

gcc.target/aarch64/pr110449.c will FAIL because the (contested)
optimization in r14-2367-g224fd59b2dc8a5 was only applied to
loop-vect but not SLP vect.  I'll leave it to target maintainers
to either XFAIL (the optimization is bad) or remove the test.

* tree-vect-slp.cc (vect_analyze_slp): Perform single-lane
loop SLP discovery for non-grouped stores.  Move check on the root
for re-doing SLP analysis with a single lane for load/store-lanes
earlier and make sure we are dealing with a grouped access.
* tree-vect-stmts.cc (vectorizable_store): Always set
vec_num for SLP.

* gcc.dg/vect/O3-pr39675-2.c: Adjust expected number of SLP.
* gcc.dg/vect/fast-math-vect-call-1.c: Likewise.
* gcc.dg/vect/no-scevccp-slp-31.c: Likewise.
* gcc.dg/vect/slp-12b.c: Likewise.
* gcc.dg/vect/slp-12c.c: Likewise.
* gcc.dg/vect/slp-19a.c: Likewise.
* gcc.dg/vect/slp-19b.c: Likewise.
* gcc.dg/vect/slp-4-big-array.c: Likewise.
* gcc.dg/vect/slp-4.c: Likewise.
* gcc.dg/vect/slp-5.c: Likewise.
* gcc.dg/vect/slp-7.c: Likewise.
* gcc.dg/vect/slp-perm-7.c: Likewise.
* gcc.dg/vect/slp-37.c: Likewise.
* gcc.dg/vect/fast-math-vect-call-2.c: Likewise.
* gcc.dg/vect/slp-26.c: RISC-V can now SLP two instances.
* gcc.dg/vect/vect-outer-slp-3.c: Disable vectorization of
initialization loop.
* gcc.dg/vect/slp-reduc-5.c: Likewise.
* gcc.dg/vect/no-scevccp-outer-12.c: Un-XFAIL.  SLP can handle
inner loop inductions with multiple vector stmt copies.
* gfortran.dg/vect/vect-8.f90: Adjust expected number of
vectorized loops.
* gcc.target/i386/vectorize1.c: Adjust what we scan for.

5 weeks agoAVR: Remove "Atmel" from header comment.
Georg-Johann Lay [Sun, 1 Sep 2024 15:19:38 +0000 (17:19 +0200)]
AVR: Remove "Atmel" from header comment.

gcc/
* config/avr/avr.h: Remove "Atmel" from header comment.
* config/avr/avr.cc: Same.
* config/avr/avr.md: Same.
* config/avr/avr.opt: Same.
* config/avr/avr-dimode.md: Same.
* config/avr/avr-fixed.md: Same.
* config/avr/constraints.md: Same.
* config/avr/predicates.md: Same.
* config/avr/avr-log.cc: Same.
* config/avr/avrlibc.h: Same.
* config/avr/specs.h: Same.
* common/config/avr/avr-common.cc: Same.
* doc/install.texi: Same.
* config/avr/avr-arch.h: Adjust header comment.
* config/avr/avr-c.cc: Same.
* config/avr/avr-mcus.def: Same.
* config/avr/avr-modes.def: Same.
* config/avr/avr-passes.cc: Same.
* config/avr/avr-passes.def: Same.
* config/avr/avr-protos.h: Same.
* config/avr/driver-avr.cc: Same.
* config/avr/elf.h: Same.
* config/avr/gen-avr-mmcu-specs.cc: Same.
* config/avr/gen-avr-mmcu-texi.cc: Same.

5 weeks agotree-optimization/116610 - wrong SLP induction bias for mask peeling
Richard Biener [Thu, 5 Sep 2024 09:18:57 +0000 (11:18 +0200)]
tree-optimization/116610 - wrong SLP induction bias for mask peeling

The following fixes a mistake when applying the bias for peeling via
masking to the inital value of SLP inductions.

This resolves gcc.target/aarch64/sve/peel_ind_1.c (a scan-assembler
only unfortunately) when forcing single-lane SLP for it.

PR tree-optimization/116610
* tree-vect-loop.cc (vectorizable_induction): Use MINUS_EXPR
to apply a mask peeling adjustment.

5 weeks agotree-optimization/116609 - SLP live lane vectorization with partial vectors
Richard Biener [Thu, 5 Sep 2024 08:46:58 +0000 (10:46 +0200)]
tree-optimization/116609 - SLP live lane vectorization with partial vectors

The following implements the simple case of single-lane SLP when
using partial vectors which can use the VEC_EXTRACT_LAST code
generation without changes.  I'll keep the PR open for further
enhancements.

This avoids FAILs of gcc.target/aarch64/sve/live_1.c when using
single-lane SLP for non-grouped stores.

PR tree-optimization/116609
* tree-vect-loop.cc (vectorizable_live_operation_1): Support
partial vectors for single-lane SLP.

5 weeks ago[PATCH 2/2 v2] RISC-V: Constant synthesis of inverted halves
Raphael Moreira Zinsly [Fri, 6 Sep 2024 04:14:32 +0000 (22:14 -0600)]
[PATCH 2/2 v2] RISC-V: Constant synthesis of inverted halves

Changes since v1:
- Fix synthesis-15.c.

-- >8 --

Improve handling of constants where the high half can be constructed by
inverting the lower half.

gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_build_integer): Detect constants
were the higher half is the lower half inverted.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/synthesis-15.c: New test.

5 weeks ago[PATCH 1/2 v2] RISC-V: Additional large constant synthesis improvements
Raphael Moreira Zinsly [Fri, 6 Sep 2024 03:50:54 +0000 (21:50 -0600)]
[PATCH 1/2 v2] RISC-V: Additional large constant synthesis improvements

Changes since v1:
- Fix bit31.
- Remove negative shift checks.
- Fix synthesis-7.c expected output.

-- >8 --

Improve handling of large constants in riscv_build_integer, generate
better code for constants where the high half can be constructed
by shifting/shiftNadding the low half or if the halves differ by less
than 2k.

gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_build_integer): Detect new case
of constants that can be improved.
(riscv_move_integer): Add synthesys for concatening constants
without Zbkb.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/synthesis-7.c: Adjust expected output.
* gcc.target/riscv/synthesis-12.c: New test.
* gcc.target/riscv/synthesis-13.c: New test.
* gcc.target/riscv/synthesis-14.c: New test.

5 weeks agoMatch: Add int type fits check for form 2 of .SAT_SUB imm operand
Pan Li [Mon, 2 Sep 2024 03:33:08 +0000 (11:33 +0800)]
Match: Add int type fits check for form 2 of .SAT_SUB imm operand

This patch would like to add strict check for imm operand of .SAT_SUB
matching.  We have no type checking for imm operand in previous, which
may result in unexpected IL to be catched by .SAT_SUB pattern.

We leverage the int_fits_type_p here to make sure the imm operand is
a int type fits the result type of the .SAT_SUB.  For example:

Fits uint8_t:
uint8_t a;
uint8_t sum = .SAT_SUB (a, 12);
uint8_t sum = .SAT_SUB (a, 12u);
uint8_t sum = .SAT_SUB (a, 126u);
uint8_t sum = .SAT_SUB (a, 128u);
uint8_t sum = .SAT_SUB (a, 228);
uint8_t sum = .SAT_SUB (a, 223u);

Not fits uint8_t:
uint8_t a;
uint8_t sum = .SAT_SUB (a, -1);
uint8_t sum = .SAT_SUB (a, 256u);
uint8_t sum = .SAT_SUB (a, 257);

The below test suite are passed for this patch:
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Add int_fits_type_p check for .SAT_SUB imm operand.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat_u_add_imm_type_check-57.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-58.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-59.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-60.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 weeks agoMatch: Add int type fits check for form 1 of .SAT_SUB imm operand
Pan Li [Mon, 2 Sep 2024 01:48:46 +0000 (09:48 +0800)]
Match: Add int type fits check for form 1 of .SAT_SUB imm operand

This patch would like to add strict check for imm operand of .SAT_SUB
matching.  We have no type checking for imm operand in previous, which
may result in unexpected IL to be catched by .SAT_SUB pattern.

We leverage the int_fits_type_p here to make sure the imm operand is
a int type fits the result type of the .SAT_SUB.  For example:

Fits uint8_t:
uint8_t a;
uint8_t sum = .SAT_SUB (12, a);
uint8_t sum = .SAT_SUB (12u, a);
uint8_t sum = .SAT_SUB (126u, a);
uint8_t sum = .SAT_SUB (128u, a);
uint8_t sum = .SAT_SUB (228, a);
uint8_t sum = .SAT_SUB (223u, a);

Not fits uint8_t:
uint8_t a;
uint8_t sum = .SAT_SUB (-1, a);
uint8_t sum = .SAT_SUB (256u, a);
uint8_t sum = .SAT_SUB (257, a);

The below test suite are passed for this patch:
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Add int_fits_type_p check for .SAT_SUB imm operand.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat_u_add_imm_type_check-53.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-54.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-55.c: New test.
* gcc.target/riscv/sat_u_add_imm_type_check-56.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 weeks agoRISC-V: Fix out of index in riscv_select_multilib_by_abi
YunQiang Su [Thu, 5 Sep 2024 11:55:20 +0000 (19:55 +0800)]
RISC-V: Fix out of index in riscv_select_multilib_by_abi

commit b5c2aae48723c9098a8a3dab1409b30fd87bbf56
Author: YunQiang Su <yunqiang@isrc.iscas.ac.cn>
Date:   Thu Sep 5 15:14:43 2024 +0800

    RISC-V: Lookup reversely in riscv_select_multilib_by_abi

The last element should use index
   multilib_infos.size () - 1

gcc
* common/config/riscv/riscv-common.cc(riscv_select_multilib_by_abi):
Fix out of index problem.

5 weeks agoc-family: add attribute flag_enum [PR81665]
Jason Merrill [Thu, 29 Aug 2024 15:09:21 +0000 (11:09 -0400)]
c-family: add attribute flag_enum [PR81665]

Several PRs complain about -Wswitch warning about a case for a bitwise
combination of enumerators.  Clang has an attribute flag_enum to prevent
this; let's adopt that approach as well.

This also recognizes the attribute as [[clang::flag_enum]], introducing
handling of the clang attribute namespace.

PR c++/46457
PR c++/81665

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_flag_enum_attribute): New.
(c_common_gnu_attributes): Add it.
(c_common_clang_attributes, c_common_clang_attribute_table): New.
* c-common.h: Declare c_common_clang_attribute_table.
* c-warn.cc (c_do_switch_warnings): Handle flag_enum.

gcc/c/ChangeLog:

* c-objc-common.h (c_objc_attribute_table): Add
c_common_clang_attribute_table.

gcc/cp/ChangeLog:

* cp-objcp-common.h (cp_objcp_attribute_table): Add
c_common_clang_attribute_table.

gcc/testsuite/ChangeLog:

* c-c++-common/attr-flag-enum-1.c: New test.

gcc/ChangeLog:

* doc/extend.texi: Document flag_enum attribute.
* doc/invoke.texi: Mention flag_enum in -Wswitch.

libstdc++-v3/ChangeLog:

* include/bits/regex_constants.h: Use flag_enum.

5 weeks agolibstdc++: -Wswitch and ios::openmode
Jason Merrill [Tue, 27 Aug 2024 17:16:27 +0000 (13:16 -0400)]
libstdc++: -Wswitch and ios::openmode

In addition to marking it as flag_enum, we want to avoid warnings about
not having a case for the implementation detail enumerators
_S_ios_openmode_*.  And also for _S_noreplace in standard modes before it
was added.

libstdc++-v3/ChangeLog:

* include/bits/ios_base.h (_GLIBCXX_NOREPLACE_UNUSED): New.
(_Ios_Openmode): Add unused attributes.
* testsuite/27_io/ios_base/types/openmode/case_label.cc: Handle
noreplace.

5 weeks agoHandle const0_operand for *avx2_pcmp<mode>3_1.
liuhongt [Wed, 4 Sep 2024 07:39:17 +0000 (15:39 +0800)]
Handle const0_operand for *avx2_pcmp<mode>3_1.

*<avx512>_eq<mode>3<mask_scalar_merge_name>_1 supports
nonimm_or_0_operand for op1 and op2, pass_combine would fail to lower
avx512 comparision back to avx2 one when op1/op2 is const0_rtx. It's
because the splitter only support nonimmediate_operand.

Failed to match this instruction:
(set (reg/i:V16QI 20 xmm0)
    (vec_merge:V16QI (const_vector:V16QI [
                (const_int -1 [0xffffffffffffffff]) repeated x16
            ])
        (const_vector:V16QI [
                (const_int 0 [0]) repeated x16
            ])
        (unspec:HI [
                (reg:V16QI 105 [ a ])
                (const_vector:V16QI [
                        (const_int 0 [0]) repeated x16
                    ])
                (const_int 0 [0])
            ] UNSPEC_PCMP)))

The patch extend predicates of the splitter to handles that.

gcc/ChangeLog:

PR target/115517
* config/i386/sse.md (*avx2_pcmp<mode>3_1): Change predicate
of operands[1] and operands[2] from nonimmdiate_operand to
nonimm_or_0_operand.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr115517.c: New test.

5 weeks agoDaily bump.
GCC Administrator [Fri, 6 Sep 2024 00:19:10 +0000 (00:19 +0000)]
Daily bump.

5 weeks ago[V2][RISC-V] Avoid unnecessary extensions after sCC insns
Jeff Law [Thu, 5 Sep 2024 21:45:25 +0000 (15:45 -0600)]
[V2][RISC-V] Avoid unnecessary extensions after sCC insns

So the first patch failed the pre-commit CI; it didn't fail in my testing
because I'm using --with-arch to set a default configuration that includes
things like zicond to ensure that's always tested.  And the failing test is
skipped when zicond is enabled by default.

The failing test is designed to ensure that we don't miss an if-conversion due
to costing issues around the extension that was typically done in an sCC
sequence (which is why it's only run when zicond is off).

The test failed because we have a little routine that is highly dependent on
the code generated by the sCC expander and will adjust the costing to account
for expansion quirks that usually go away in register allocation.

That code needs to be enhanced to work after the sCC expansion change.
Essentially it needs to account for the subreg extraction that shows up in the
sequence as well as being a bit looser on mode checking.

I kept the code working for the old sequences -- in theory a user could conjure
up the old sequence so handling them seems useful.

This also drops the testsuite changes.  Palmer's change makes them unnecessary.

---

So I was looking at a performance regression in spec with Ventana's internal
tree.  Ultimately the problem was a bad interaction with an internal patch
(REP_MODE_EXTENDED), fwprop and ext-dce.  The details of that problem aren't
particularly important.

Removal of the local patch went reasonably well.  But I did see some secondary
cases where we had redundant sign extensions.  The most notable cases come from
the integer sCC insns.

Expansion of those cases for rv64 can be improved using Jivan's trick. ie, if
the target is not DImode, then create a DImode temporary for the result and
copy the low bits out with a promoted subreg to the real target.

With the change in expansion the final code we generate is slightly different
for a few tests at -O1/-Og, but should perform the same.  The key for the
affected tests is we're not seeing the introduction of unnecessary extensions.
Rather than adjust the regexps to handle the -O1/-Og output, skipping for those
seemed OK to me.  I didn't extract a testcase.  I'm a bit fried from digging
through LTO'd code right now.

gcc/
* config/riscv/riscv.cc (riscv_expand_int_scc): For rv64, use a DI
temporary for the output and a promoted subreg to extract it into SI
arget.
(riscv_noce_conversion_profitable_p): Recognize new output from
sCC expansion too.

5 weeks agoc++: tweak redeclaration-6.C
Jason Merrill [Thu, 5 Sep 2024 20:39:55 +0000 (16:39 -0400)]
c++: tweak redeclaration-6.C

gcc/testsuite/ChangeLog:

* g++.dg/diagnostic/redeclaration-6.C: Add -fno-implicit-constexpr.

5 weeks agoFortran: fix ICE in gfc_create_module_variable [PR100273]
Harald Anlauf [Thu, 5 Sep 2024 19:30:25 +0000 (21:30 +0200)]
Fortran: fix ICE in gfc_create_module_variable [PR100273]

gcc/fortran/ChangeLog:

PR fortran/100273
* trans-decl.cc (gfc_create_module_variable): Handle module
variable also when it is needed for the result specification
of a contained function.

gcc/testsuite/ChangeLog:

PR fortran/100273
* gfortran.dg/pr100273.f90: New test.

5 weeks agoc++: vtable referring to "unavailable" virtual fn [PR116606]
Marek Polacek [Thu, 5 Sep 2024 17:01:59 +0000 (13:01 -0400)]
c++: vtable referring to "unavailable" virtual fn [PR116606]

mark_vtable_entries already has

   /* It's OK for the vtable to refer to deprecated virtual functions.  */
   warning_sentinel w(warn_deprecated_decl);

but that doesn't cover __attribute__((unavailable)).  We can use the
following override to cover both.

PR c++/116606

gcc/cp/ChangeLog:

* decl2.cc (mark_vtable_entries): Temporarily override deprecated_state to
UNAVAILABLE_DEPRECATED_SUPPRESS.  Remove a warning_sentinel.

gcc/testsuite/ChangeLog:

* g++.dg/ext/attr-unavailable-13.C: New test.

5 weeks agoc++, coroutines: Revise promise construction/destruction.
Iain Sandoe [Sat, 31 Aug 2024 12:08:42 +0000 (13:08 +0100)]
c++, coroutines: Revise promise construction/destruction.

In examining the coroutine testcases for unexpected diagnostic output
for 'Wall', I found a 'statement has no effect' warning for the promise
construction in one case.  In particular, the case is where the users
promise type has an implicit CTOR but a user-provided DTOR. Further, the
type does not actually need constructing.

In very early versions of the coroutines code we used to check
TYPE_NEEDS_CONSTRUCTING() to determine whether to attempt to build
a constructor call for the promise.  During review, it was suggested
to use type_build_ctor_call () instead.

This latter call checks the constructors in the type (both user-defined
and implicit) and returns true, amongst other cases if any of the found
CTORs are marked as deprecated.

In a number of places (for example [class.copy.ctor] / 6) the standard
says that some version of an implicit CTOR is deprecated when the user
provides a DTOR.

Thus, for this specific arrangement of promise type, type_build_ctor_call
returns true, because of (for example) a deprecated implicit copy CTOR.

We are not going to use any of the deprecated CTORs and thus will not
see warnings from this - however, since the call returned true, we have
now determined that we should attempt to build a constructor call.

Note as above, the type does not actually require construction and thus
one might expect either a NULL_TREE or error_mark_node in response to
the build_special_member_call ().  However, in practice the function
returns the original instance object instead of a call or some error.

When we add that as a statement it triggers the 'statement has no effect'
warning.

The patch here rearranges the promise construction/destruction code to
allow for the case that a DTOR is required independently of a CTOR. In
addition, we check that the return from build_special_member_call ()
has side effects before we add it as a statement.

gcc/cp/ChangeLog:

* coroutines.cc
(cp_coroutine_transform::build_ramp_function): Separate the
build of promise constructor and destructor.  When evaluating
the constructor, check that build_special_member_call returns
an expression with side effects before adding it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 weeks agoc++: local class memfn synth from noexcept context [PR113063]
Patrick Palka [Thu, 5 Sep 2024 18:31:00 +0000 (14:31 -0400)]
c++: local class memfn synth from noexcept context [PR113063]

Extending the PR113063 testcase to additionally constant evaluate the <=>
expression causes us to trip over the assert in cxx_eval_call_expression

  /* We used to shortcut trivial constructor/op= here, but nowadays
     we can only get a trivial function here with -fno-elide-constructors.  */
  gcc_checking_assert (!trivial_fn_p (fun)
                       || !flag_elide_constructors
                       /* We don't elide constructors when processing
                          a noexcept-expression.  */
                       || cp_noexcept_operand);

since the local class's <=> was first used and therefore synthesized in
a noexcept context and so its definition contains unelided trivial
constructors.

This patch fixes this by clearing cp_noexcept_operand alongside
cp_unevaluated_context in the function-local case of
maybe_push_to_top_level.

PR c++/113063

gcc/cp/ChangeLog:

* name-lookup.cc (local_state_t): Clear and restore
cp_noexcept_operand as well.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-synth16.C: Also constant evaluate
the <=> expression.
* g++.dg/cpp2a/spaceship-synth16a.C: Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
5 weeks agodoc: remove stray character
Marek Polacek [Thu, 5 Sep 2024 17:17:06 +0000 (13:17 -0400)]
doc: remove stray character

There's an extra '+'.

gcc/ChangeLog:

* doc/invoke.texi: Remove an extra char in @item sme2.

5 weeks agoc++: fn redecl in fn scope wrongly accepted [PR116239]
Marek Polacek [Fri, 30 Aug 2024 18:12:22 +0000 (14:12 -0400)]
c++: fn redecl in fn scope wrongly accepted [PR116239]

Redeclaration such as

  void f(void);
  consteval void f(void);

is invalid.  In a namespace scope, we detect the collision in
validate_constexpr_redeclaration, but not when one declaration is
at block scope.

When we have

  void f(void);
  void g() { consteval void f(void); }

we call pushdecl on the second f and call push_local_extern_decl_alias.
It finds the namespace-scope f:

        for (ovl_iterator iter (binding); iter; ++iter)
          if (decls_match (decl, *iter, /*record_versions*/false))
            {
              alias = *iter;
              break;
            }

but decls_match says they match so we just set DECL_LOCAL_DECL_ALIAS
(and do not call another pushdecl leading to duplicate_decls which
would detect mismatching return types, for example).  I don't think
we want to change decls_match, so a simple fix is to detect the
problem in push_local_extern_decl_alias.

PR c++/116239

gcc/cp/ChangeLog:

* cp-tree.h (validate_constexpr_redeclaration): Declare.
* decl.cc (validate_constexpr_redeclaration): No longer static.
* name-lookup.cc (push_local_extern_decl_alias): Call
validate_constexpr_redeclaration.

gcc/testsuite/ChangeLog:

* g++.dg/diagnostic/redeclaration-6.C: New test.

5 weeks agoAvoid ICE when passing VLA vector to accelerator.
Prathamesh Kulkarni [Thu, 5 Sep 2024 13:22:53 +0000 (18:52 +0530)]
Avoid ICE when passing VLA vector to accelerator.

gcc/ChangeLog:
* gimplify.cc (omp_add_variable): Check if decl size is not poly_int_tree_p.
(gimplify_adjust_omp_clauses): Likewise.
* omp-low.cc (scan_sharing_clauses): Likewise.
(lower_omp_target): Likewise.

Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
5 weeks agonvptx: Emit DECL and DEF linker markers for aliases [PR104957]
Thomas Schwinge [Wed, 17 Jul 2024 21:56:25 +0000 (23:56 +0200)]
nvptx: Emit DECL and DEF linker markers for aliases [PR104957]

With nvptx '-malias' enabled (as implemented in
commit f8b15e177155960017ac0c5daef8780d1127f91c
"[nvptx] Use .alias directive for mptx >= 6.3"), the C++ front end in certain
cases does 'write_fn_proto' before an eventual 'alias' attribute has been
added.  In that case, we do emit (via 'write_fn_marker') a DECL linker marker,
but then never emit a corresponding DEF linker marker for the alias.  This
causes hundreds of instances of link-time 'unresolved symbol [alias]' across
the C++ test suite, which are regressions compared to a test run with (default)
'-mno-alias' (in which case the respective functions get duplicated).

PR target/104957
gcc/
* config/nvptx/nvptx.cc (write_fn_proto_1): Revert 2022-03-22
change; 'write_fn_marker' also for alias DECL.
(nvptx_asm_output_def_from_decls): 'write_fn_marker' for alias
DEF.
gcc/testsuite/
* g++.target/nvptx/alias-g++.dg_init_dtor2-1.C: Un-XFAIL.
* gcc.target/nvptx/alias-1.c: Likewise.
* gcc.target/nvptx/alias-3.c: Likewise.
* gcc.target/nvptx/alias-to-alias-1.c: Likewise.

5 weeks agoAdd 'g++.target/nvptx/alias-g++.dg_init_dtor2-1.C'
Thomas Schwinge [Wed, 17 Jul 2024 16:02:50 +0000 (18:02 +0200)]
Add 'g++.target/nvptx/alias-g++.dg_init_dtor2-1.C'

... as one minimized example for the issue that with nvptx '-malias' enabled
(as implemented in commit f8b15e177155960017ac0c5daef8780d1127f91c
"[nvptx] Use .alias directive for mptx >= 6.3"), there are hundreds of
instances of link-time 'unresolved symbol [alias]' across the C++ test suite,
which are regressions compared to a test run with (default) '-mno-alias'.

PR target/104957
gcc/testsuite/
* g++.target/nvptx/alias-g++.dg_init_dtor2-1.C: Add.

5 weeks agoEnhance 'gcc.target/nvptx/alias-*.c' assembler scanning
Thomas Schwinge [Wed, 17 Jul 2024 13:27:51 +0000 (15:27 +0200)]
Enhance 'gcc.target/nvptx/alias-*.c' assembler scanning

... in order to demonstrate unexpected behavior (XFAILed here).

PR target/104957
gcc/testsuite/
* gcc.target/nvptx/alias-1.c: Enhance assembler scanning.
* gcc.target/nvptx/alias-2.c: Likewise.
* gcc.target/nvptx/alias-3.c: Likewise.
* gcc.target/nvptx/alias-4.c: Likewise.
* gcc.target/nvptx/alias-to-alias-1.c: Likewise.

5 weeks agoFix 'gcc.target/nvptx/alias-2.c' comment
Thomas Schwinge [Mon, 18 Sep 2023 20:41:56 +0000 (22:41 +0200)]
Fix 'gcc.target/nvptx/alias-2.c' comment

PR target/104957
gcc/testsuite/
* gcc.target/nvptx/alias-2.c: Fix comment.

5 weeks agoMove from 'gcc.target/nvptx/nvptx.exp' into 'target-supports.exp' additions for nvptx...
Thomas Schwinge [Mon, 22 Jul 2024 12:40:34 +0000 (14:40 +0200)]
Move from 'gcc.target/nvptx/nvptx.exp' into 'target-supports.exp' additions for nvptx target

gcc/testsuite/
* gcc.target/nvptx/nvptx.exp
(check_effective_target_default_ptx_isa_version_at_least)
(check_effective_target_default_ptx_isa_version_at_least_6_0)
(check_effective_target_runtime_ptx_isa_version_at_least)
(check_effective_target_runtime_ptx_alias)
(add_options_for_ptx_alias): Move...
* lib/target-supports.exp
(check_nvptx_default_ptx_isa_version_at_least)
(check_effective_target_nvptx_default_ptx_isa_version_at_least_6_0)
(check_nvptx_runtime_ptx_isa_version_at_least)
(check_effective_target_nvptx_runtime_alias_ptx)
(add_options_for_nvptx_alias_ptx): ... here.
* gcc.target/nvptx/alias-1.c: Adjust.
* gcc.target/nvptx/alias-2.c: Likewise.
* gcc.target/nvptx/alias-3.c: Likewise.
* gcc.target/nvptx/alias-4.c: Likewise.
* gcc.target/nvptx/alias-to-alias-1.c: Likewise.
* gcc.target/nvptx/alias-weak-1.c: Likewise.
* gcc.target/nvptx/uniform-simt-5.c: Likewise.
gcc/
* doc/sourcebuild.texi (Effective-Target Keywords): Document
'nvptx_default_ptx_isa_version_at_least_6_0',
'nvptx_runtime_alias_ptx'.
(Add Options): Document 'nvptx_alias_ptx'.

5 weeks agoc++: Add missing auto_diagnostic_groups
Nathaniel Shead [Wed, 7 Aug 2024 09:20:19 +0000 (19:20 +1000)]
c++: Add missing auto_diagnostic_groups

This patch goes through all .cc files in gcc/cp and adds in any
auto_diagnostic_groups that seem to be missing by looking for any
'inform' calls that aren't grouped with their respective error/warning.
Now with SARIF output support this seems to be a bit more important.

The patch isn't complete; I've tried to also track helper functions used
for diagnostics to group them, but some may have been missed.
Additionally there are a few functions that are definitely missing
groupings but I wasn't able to see an obvious way to add them without
potentially grouping together unrelated messages.

This list includes:

- lazy_load_{binding,pendings} "during load of {binding,pendings} for"
- cp_finish_decomp "in initialization of structured binding variable"
- require_deduced_type "using __builtin_source_location"
- convert_nontype_argument "in template argument for type %qT"
- coerce_template_params "so any instantiation with a non-empty parameter pack"
- tsubst_default_argument "when instantiating default argument"
- invalid_nontype_parm_type_p "invalid template non-type parameter"

gcc/cp/ChangeLog:

* class.cc (add_method): Add missing auto_diagnostic_group.
(handle_using_decl): Likewise.
(maybe_warn_about_overly_private_class): Likewise.
(check_field_decl): Likewise.
(check_field_decls): Likewise.
(resolve_address_of_overloaded_function): Likewise.
(note_name_declared_in_class): Likewise.
* constraint.cc (associate_classtype_constraints): Likewise.
(diagnose_trait_expr): Clean up whitespace.
* coroutines.cc (find_coro_traits_template_decl): Add missing
auto_diagnostic_group.
(coro_promise_type_found_p): Likewise.
(coro_diagnose_throwing_fn): Likewise.
* cvt.cc (build_expr_type_conversion): Likewise.
* decl.cc (validate_constexpr_redeclaration): Likewise.
(duplicate_function_template_decls): Likewise.
(duplicate_decls): Likewise.
(lookup_label_1): Likewise.
(check_previous_goto_1): Likewise.
(check_goto_1): Likewise.
(make_typename_type): Likewise.
(make_unbound_class_template): Likewise.
(check_tag_decl): Likewise.
(start_decl): Likewise.
(maybe_commonize_var): Likewise.
(check_for_uninitialized_const_var): Likewise.
(reshape_init_class): Likewise.
(check_initializer): Likewise.
(cp_finish_decl): Likewise.
(find_decomp_class_base): Likewise.
(cp_finish_decomp): Likewise.
(expand_static_init): Likewise.
(grokfndecl): Likewise.
(grokdeclarator): Likewise.
(check_elaborated_type_specifier): Likewise.
(lookup_and_check_tag): Likewise.
(xref_tag): Likewise.
(cxx_simulate_enum_decl): Likewise.
(finish_function): Likewise.
* decl2.cc (check_classfn): Likewise.
(record_mangling): Likewise.
(mark_used): Likewise.
* error.cc (qualified_name_lookup_error): Likewise.
* except.cc (build_throw): Likewise.
* init.cc (get_nsdmi): Likewise.
(diagnose_uninitialized_cst_or_ref_member_1): Likewise.
(warn_placement_new_too_small): Likewise.
(build_new_1): Likewise.
(build_vec_delete_1): Likewise.
(build_delete): Likewise.
* lambda.cc (add_capture): Likewise.
(add_default_capture): Likewise.
* lex.cc (unqualified_fn_lookup_error): Likewise.
* method.cc (synthesize_method): Likewise.
(defaulted_late_check): Likewise.
* module.cc (trees_in::is_matching_decl): Likewise.
(trees_in::read_enum_def): Likewise.
(module_state::check_not_purview): Likewise.
(module_state::deferred_macro): Likewise.
(module_state::read_config): Likewise.
(module_state::check_read): Likewise.
(declare_module): Likewise.
(init_modules): Likewise.
* name-lookup.cc (diagnose_name_conflict): Likewise.
(lookup_using_decl): Likewise.
(set_decl_namespace): Likewise.
(finish_using_directive): Likewise.
(push_namespace): Likewise.
(add_imported_namespace): Likewise.
* parser.cc (cp_parser_check_for_definition_in_return_type): Likewise.
(cp_parser_userdef_numeric_literal): Likewise.
(cp_parser_nested_name_specifier_opt): Likewise.
(cp_parser_new_expression): Likewise.
(cp_parser_binary_expression): Likewise.
(cp_parser_lambda_introducer): Likewise.
(cp_parser_module_declaration): Likewise.
(cp_parser_import_declaration): Likewise, removing gotos to
support this.
(cp_parser_declaration): Add missing auto_diagnostic_group.
(cp_parser_decl_specifier_seq): Likewise.
(cp_parser_template_id): Likewise.
(cp_parser_template_name): Likewise.
(cp_parser_explicit_specialization): Likewise.
(cp_parser_placeholder_type_specifier): Likewise.
(cp_parser_elaborated_type_specifier): Likewise.
(cp_parser_enum_specifier): Likewise.
(cp_parser_asm_definition): Likewise.
(cp_parser_init_declarator): Likewise.
(cp_parser_direct_declarator): Likewise.
(cp_parser_class_head): Likewise.
(cp_parser_member_declaration): Likewise.
(cp_parser_lookup_name): Likewise.
(cp_parser_explicit_template_declaration): Likewise.
(cp_parser_check_class_key): Likewise.
* pt.cc (maybe_process_partial_specialization): Likewise.
(determine_specialization): Likewise.
(check_for_bare_parameter_packs): Likewise.
(check_template_shadow): Likewise.
(process_partial_specialization): Likewise.
(push_template_decl): Likewise.
(redeclare_class_template): Likewise.
(convert_nontype_argument_function): Likewise.
(check_valid_ptrmem_cst_expr): Likewise.
(convert_nontype_argument): Likewise.
(convert_template_argument): Likewise.
(coerce_template_parms): Likewise.
(tsubst_qualified_id): Likewise.
(tsubst_expr): Likewise.
(most_specialized_partial_spec): Likewise.
(do_class_deduction): Likewise.
(do_auto_deduction): Likewise.
* search.cc (lookup_member): Likewise.
* semantics.cc (finish_non_static_data_member): Likewise.
(process_outer_var_ref): Likewise.
(finish_id_expression_1): Likewise.
(finish_offsetof): Likewise.
(omp_reduction_lookup): Likewise.
(finish_omp_clauses): Likewise.
* tree.cc (check_abi_tag_redeclaration): Likewise.
(check_abi_tag_args): Likewise.
* typeck.cc (invalid_nonstatic_memfn_p): Likewise.
(complain_about_unrecognized_member): Likewise.
(finish_class_member_access_expr): Likewise.
(error_args_num): Likewise.
(warn_for_null_address): Likewise.
(cp_build_binary_op): Likewise.
(build_x_unary_op): Likewise.
(cp_build_unary_op): Likewise.
(build_static_cast): Likewise.
(cp_build_modify_expr): Likewise.
(get_delta_difference): Likewise.
(convert_for_assignment): Widen scope of auto_diagnostic_group.
(check_return_expr): Add missing auto_diagnostic_group.
* typeck2.cc (cxx_incomplete_type_diagnostic): Likewise.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Marek Polacek <polacek@redhat.com>
5 weeks ago[AARCH64] adjust gcc.target/aarch64/sve/mask_gather_load_7.c
Richard Biener [Thu, 5 Sep 2024 09:38:04 +0000 (11:38 +0200)]
[AARCH64] adjust gcc.target/aarch64/sve/mask_gather_load_7.c

The following adjusts the scan-assembler to also allow predicate
registers p8-15 to be used for the destination of the compares.
I see that code generation with a pending vectorizer patch (the
only assembler change is different predicate register allocation).

* gcc.target/aarch64/sve/mask_gather_load_7.c: Allow
p8-15 to be used for the destination of the compares.

5 weeks agolibsanitizer: On aarch64 use hint #34 in prologue of libsanitizer functions
Jakub Jelinek [Thu, 5 Sep 2024 10:20:57 +0000 (12:20 +0200)]
libsanitizer: On aarch64 use hint #34 in prologue of libsanitizer functions

When gcc is built with -mbranch-protection=standard, running sanitized
programs doesn't work properly on bti enabled kernels.

This has been fixed upstream with
https://github.com/llvm/llvm-project/pull/84061

The following patch cherry picks that from upstream.

For trunk we should eventually do a full merge from upstream, but I'm hoping
they will first fix up the _BitInt libubsan support mess.

2024-09-05  Jakub Jelinek  <jakub@redhat.com>

* sanitizer_common/sanitizer_asm.h: Cherry-pick llvm-project revision
1c792d24e0a228ad49cc004a1c26bbd7cd87f030.
* interception/interception.h: Likewise.

5 weeks agomiddle-end: have vect_recog_cond_store_pattern use pattern statement for cond if...
Tamar Christina [Thu, 5 Sep 2024 09:36:55 +0000 (10:36 +0100)]
middle-end: have vect_recog_cond_store_pattern use pattern statement for cond if available

When vectorizing a conditional operation we rely on the bool_recog pattern to
hit and convert the bool of the operand to a valid mask.

However we are currently not using the converted operand as this is in a pattern
statement.  This change updates it to look at the actual statement to be
vectorized so we pick up the pattern.

Note that there are no tests here since vectorization will fail until we
correctly lower all boolean conditionals early.

Tests for these are in the next patch, namely vect-conditional_store_5.c and
vect-conditional_store_6.c.  And the existing vect-conditional_store_[1-4].c
checks that the other cases are still handled correctly.

gcc/ChangeLog:

* tree-vect-patterns.cc (vect_recog_cond_store_pattern): Use pattern
statement.

5 weeks agotestsuite: remove -fwrapv from signbit-5.c
Tamar Christina [Thu, 5 Sep 2024 09:36:02 +0000 (10:36 +0100)]
testsuite: remove -fwrapv from signbit-5.c

The meaning of the testcase was changed by passing it -fwrapv.  The reason for
the test failures on some platform was because the test was testing some
implementation defined behavior wrt INT_MIN in generic code.

Instead of using -fwrapv this just removes the border case from the test so
all the values now have a defined semantic.  It still relies on the handling of
shifting a negative value right, but that wasn't changed with -fwrapv anyway.

The -fwrapv case is being handled already by other testcases.

gcc/testsuite/ChangeLog:

* gcc.dg/signbit-5.c: Remove -fwrapv and change INT_MIN to INT_MIN+1.

5 weeks agodocs: double mention of armv9-a.
Tamar Christina [Thu, 5 Sep 2024 09:35:18 +0000 (10:35 +0100)]
docs: double mention of armv9-a.

The list of available architecture for Arm is incorrectly listing armv9-a twice.
This removes the duplicate armv9-a enumeration from the part of the list having
M-profile targets.

gcc/ChangeLog:

* doc/invoke.texi: Remove duplicate armv9-a mention.

5 weeks agovrp: Fix up diagnostics wording
Jakub Jelinek [Thu, 5 Sep 2024 09:06:12 +0000 (11:06 +0200)]
vrp: Fix up diagnostics wording

I've noticed non-standard wording of this diagnostics when looking at
a miscompilation with --param=vrp-block-limit=0.

Diagnostics generally shouldn't start with uppercase letter (unless
the upper case would appear also in the middle of a sentence) and shouldn't
be separate sentences with dot as separator, ; is IMHO more frequently used.

2024-09-05  Jakub Jelinek  <jakub@redhat.com>

* tree-vrp.cc (pass_vrp::execute): Start diagnostics with
lowercase u rather than capital U, use semicolon instead of dot.

5 weeks agoRISC-V: Lookup reversely in riscv_select_multilib_by_abi
YunQiang Su [Thu, 5 Sep 2024 07:14:43 +0000 (15:14 +0800)]
RISC-V: Lookup reversely in riscv_select_multilib_by_abi

When use --print-multi-os-dir or -print-multi-directory, gcc outputs
different values with full -march option and the base one only.

$ ./gcc/xgcc --print-multi-os-dir -mabi=lp64d -march=rv64gc
lib64/lp64d

$ ./gcc/xgcc --print-multi-os-dir -mabi=lp64d -march=rv64gc_zba
.

The reason is that in multilib.h, the fallback value of multilib
is listed as the 1st one in `multilib_raw[]`.

gcc
* common/config/riscv/riscv-common.cc(riscv_select_multilib_by_abi):
look up reversely as the fallback path is listed as the 1st one.

5 weeks agotestsuite: Fix xorsign.c, vect-double-2.c fails with -march=x86-64-v2
Hu, Lin1 [Thu, 5 Sep 2024 06:51:42 +0000 (14:51 +0800)]
testsuite: Fix xorsign.c, vect-double-2.c fails with -march=x86-64-v2

These testcases raise fails with -march=x86-64-v2, so add -mno-sse4 to avoid
these unexpected fails.

gcc/testsuite/ChangeLog:

PR testsuite/116608
* gcc.target/i386/vect-double-2.c: Add extra option -mno-sse4
* gcc.target/i386/xorsign.c: Ditto.

5 weeks agoada: Add bypass for internal fields on strict-alignment platforms
Eric Botcazou [Mon, 26 Aug 2024 09:16:41 +0000 (11:16 +0200)]
ada: Add bypass for internal fields on strict-alignment platforms

This is required to support misalignment of tagged types in legacy code.

gcc/ada/

* gcc-interface/trans.cc (addressable_p) <COMPONENT_REF>: Add bypass
for internal fields on strict-alignment platforms.

5 weeks agoada: Streamline handling of low-level peculiarities of record field layout
Eric Botcazou [Sun, 25 Aug 2024 13:20:59 +0000 (15:20 +0200)]
ada: Streamline handling of low-level peculiarities of record field layout

This factors out the interface to the low-level field layout machinery.

gcc/ada/

* gcc-interface/gigi.h (default_field_alignment): New function.
* gcc-interface/misc.cc: Include tm_p header file.
(default_field_alignment): New function.
* gcc-interface/trans.cc (addressable_p) <COMPONENT_REF>: Replace
previous alignment klduge with call to default_field_alignment.
* gcc-interface/utils.cc (finish_record_type): Likewise for the
alignment based on which DECL_BIT_FIELD should be cleared.

5 weeks agoada: Remove unused parameters in validity checking routine
Piotr Trojanek [Mon, 26 Aug 2024 13:25:03 +0000 (15:25 +0200)]
ada: Remove unused parameters in validity checking routine

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_util.ads, exp_util.adb (Duplicate_Subexpr_No_Checks):
Remove parameters, which are no longer used.

5 weeks agoada: Integrate new diagnostics in the frontend
Viljar Indus [Tue, 18 Jun 2024 12:34:32 +0000 (15:34 +0300)]
ada: Integrate new diagnostics in the frontend

Integrate diagnostic messages using the new implementation to the codebase.

New diagnostic implementation uses GNAT.Lists as a building
block. Tampering checks that were initially implemented
for those lists are not critical for this implementation and
they lead to overly complex code.

Add a generic parameter Tampering_Checks to control whether
the tempering checks should be applied for the lists.
Make tampering checks conditional for GNAT.Lists

gcc/ada/

* par-endh.adb: add call to new diagnostic for end loop errors.
* sem_ch13.adb: add call to new diagnostic for default iterator
error and record representation being too late.
* sem_ch4.adb: Add new diagnostic for wrong operands.
* sem_ch9.adb: Add new diagnostic for a Lock_Free warning.
* libgnat/g-lists.adb (Ensure_Unlocked): Make checks for tampering
conditional.
* libgnat/g-lists.ads: Add parameter Tampering_Checks to control
whether tampering checks should be executed.
* backend_utils.adb: Add new gcc switches
'-fdiagnostics-format=sarif-file' and
'-fdiagnostics-format=sarif-stderr'.
* debug.adb: document -gnatd_D switch.
* diagnostics-brief_emitter.adb: New package for displaying
diagnostic messages in a compact manner.
* diagnostics-brief_emitter.ads: Same as above.
* diagnostics-constructors.adb: New pacakge for providing simpler
constructor methods for new diagnostic objects.
* diagnostics-constructors.ads: Same as above.
* diagnostics-converter.adb: New package for converting old
Error_Msg_Object-s to Diagnostic_Types.
* diagnostics-converter.ads: Same as above.
* diagnostics-json_utils.adb: Package for utility methods related
to emitting JSON.
* diagnostics-json_utils.ads: Same as above.
* diagnostics-pretty_emitter.adb: New package for displaying
diagnostic messages in a more elaborate manner.
* diagnostics-pretty_emitter.ads: Same as above.
* diagnostics-repository.adb: New package for collecting all
created error messages.
* diagnostics-repository.ads: Same as above.
* diagnostics-sarif_emitter.adb: New pacakge for converting all of
the diagnostics into a report in the SARIF format.
* diagnostics-sarif_emitter.ads: Same as above.
* diagnostics-switch_repository.adb: New package containing the
definitions for all of the warninging switches.
* diagnostics-switch_repository.ads: Same as above.
* diagnostics-utils.adb: Contains various utility methods for the
diagnostic pacakges.
* diagnostics-utils.ads: Same as above.
* diagnostics.adb: Contains the definitions and common functions
for all the new diagnostics objects.
* diagnostics.ads: Same as above.
* errout.adb: Relocate the old implementations for brief and
pretty printing the diagnostic messages and the entrypoint to the
new implementation if a debug switch is used.
* errout.ads: Improve documentation. Make Set_Msg_Text publicly
available.
* opt.ads: Add the flag SARIF_File which controls whether the
diagnostic messages should be printed to a file in the SARIF
format. Add the flag SARIF_Output to control whether the
diagnostic messages should be printed to std-err in the SARIF
format.
* gcc-interface/Make-lang.in: Add new pacakages to the object
list.
* gcc-interface/Makefile.in: Add new pacakages to the object list.

5 weeks agoada: Binder respects Ada version for checksum of runtime files
Jose Ruiz [Fri, 23 Aug 2024 16:25:13 +0000 (16:25 +0000)]
ada: Binder respects Ada version for checksum of runtime files

The parsing to compute the checksums of runtime files (within the
binder) was done using the default Ada version (Ada 2012 currently),
while the creation of the checksum, when the runtime files are
compiled, is performed in a more recent Ada version (Ada 2022
currently). This change forces the checksum computation for runtime
files to be done with the same Ada version as when they were created.

gcc/ada/

* ali-util.adb (Get_File_Checksum): Force the parsing for
the checksum computation of runtime files to be done in
the corresponding recent Ada version.

5 weeks agoada: Tweak assertions in Inline.Cannot_Inline
Ronan Desplanques [Wed, 21 Aug 2024 15:22:20 +0000 (17:22 +0200)]
ada: Tweak assertions in Inline.Cannot_Inline

The purpose of this patch is to silence a GNATSAS report.

gcc/ada/

* inline.adb (Cannot_Inline): Remove assertion.
* inline.ads (Cannot_Inline): Add precondition.

5 weeks agoHandle unused-only-live stmts in SLP discovery
Richard Biener [Thu, 7 Mar 2024 14:13:33 +0000 (15:13 +0100)]
Handle unused-only-live stmts in SLP discovery

The following adds SLP discovery for roots that are only live but
otherwise unused.  These are usually inductions.  This allows a
few more testcases to be handled fully with SLP, for example
gcc.dg/vect/no-scevccp-pr86725-1.c

* tree-vect-slp.cc (vect_analyze_slp): Analyze SLP for live
but otherwise unused defs.

5 weeks agoHandle 'NUM' in 'PUSH_INSERT_PASSES_WITHIN'
Thomas Schwinge [Fri, 28 Jun 2024 10:10:12 +0000 (12:10 +0200)]
Handle 'NUM' in 'PUSH_INSERT_PASSES_WITHIN'

..., such that also for repeated 'NEXT_PASS', 'PUSH_INSERT_PASSES_WITHIN' for a
given 'PASS', the 'PUSH_INSERT_PASSES_WITHIN' applies to the preceeding
'NEXT_PASS', and not unconditionally applies to the first 'NEXT_PASS'.

gcc/
* gen-pass-instances.awk: Handle 'PUSH_INSERT_PASSES_WITHIN'.
* pass_manager.h (PUSH_INSERT_PASSES_WITHIN): Adjust.
* passes.cc (PUSH_INSERT_PASSES_WITHIN): Likewise.

5 weeks ago[PATCH] RISC-V: Make the setCC/REE tests robust to instruction selection
Palmer Dabbelt [Thu, 5 Sep 2024 03:34:31 +0000 (21:34 -0600)]
[PATCH] RISC-V: Make the setCC/REE tests robust to instruction selection

These tests were checking that the output of the setCC instruction was bit
flipped, but it looks like they're really designed to test that
redundant sign extension elimination fires on conditionals from function
inputs.  Jeff just posed a patch to clean this code up with trips up on
the arbitrary xori/snez instruction selection decision changing, so
let's just robustify the tests.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sge.c: Adjust regex to match the input.
* gcc.target/riscv/sgeu.c: Likewise.
* gcc.target/riscv/sle.c: Likewise.
* gcc.target/riscv/sleu.c: Likewise.

5 weeks agoi386: Support partial vectorized FMA for V2BF/V4BF
Levy Hsu [Mon, 2 Sep 2024 05:52:38 +0000 (13:52 +0800)]
i386: Support partial vectorized FMA for V2BF/V4BF

This patch introduces support for vectorized FMA operations for bf16 types in
V2BF and V4BF modes on the i386 architecture. New mode iterators and
define_expand entries for fma, fnma, fms, and fnms operations are added in
mmx.md, enhancing the i386 backend to handle these complex arithmetic operations.

gcc/ChangeLog:

* config/i386/mmx.md (TARGET_MMX_WITH_SSE): New mode iterator VBF_32_64
(fma<mode>4): define_expand for V2BF/V4BF fma<mode>4.
(fnma<mode>4): define_expand for V2BF/V4BF fnma<mode>4.
(fms<mode>4): define_expand for V2BF/V4BF fms<mode>4.
(fnms<mode>4): define_expand for V2BF/V4BF fnms<mode>4.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_2-partial-bf-vector-fma-1.c: New test.

5 weeks agoMatch: Fix ordered and nonequal
Hu, Lin1 [Tue, 3 Sep 2024 07:35:30 +0000 (15:35 +0800)]
Match: Fix ordered and nonequal

Need to add :c for bit_and, because bit_and is commutative. And is (ltgt @0 @1)
is simpler than (bit_not (uneq @0 @1)).

gcc/ChangeLog:

* match.pd: Fix match for (bit_and (ordered @0 @1) (ne @0 @1)).

gcc/testsuite/ChangeLog:

* gcc.dg/opt-ordered-and-nonequal-1.c: New test.
* gcc.target/i386/optimize_one.c: Change name to opt-comi-1.c.
* gcc.target/i386/opt-comi-1.c: New test.

5 weeks agoi386: Support partial signbit/xorsign/copysign/abs/neg/and/xor/ior/andn for V2BF...
Levy Hsu [Mon, 2 Sep 2024 03:57:46 +0000 (13:27 +0930)]
i386: Support partial signbit/xorsign/copysign/abs/neg/and/xor/ior/andn for V2BF/V4BF

This patch adds support for bf16 operations in V2BF and V4BF modes on i386,
handling signbit, xorsign, copysign, abs, neg, and various logical operations.

gcc/ChangeLog:

* config/i386/i386.cc (ix86_build_const_vector): Add V2BF/V4BF.
(ix86_build_signbit_mask): Add V2BF/V4BF.
* config/i386/mmx.md: Modified supported logic op to use VHBF_32_64.

gcc/testsuite/ChangeLog:

* gcc.target/i386/part-vect-absnegbf.c: New test.

5 weeks agoi386: Integrate BFmode for Enhanced Vectorization in ix86_preferred_simd_mode
Levy Hsu [Tue, 3 Sep 2024 06:14:06 +0000 (15:44 +0930)]
i386: Integrate BFmode for Enhanced Vectorization in ix86_preferred_simd_mode

This change adds BFmode support to the ix86_preferred_simd_mode function
enhancing SIMD vectorization for BF16 operations. The update ensures
optimized usage of SIMD capabilities improving performance and aligning
vector sizes with processor capabilities.

gcc/ChangeLog:

* config/i386/i386.cc (ix86_preferred_simd_mode): Add BFmode Support.

5 weeks agoDaily bump.
GCC Administrator [Thu, 5 Sep 2024 00:19:06 +0000 (00:19 +0000)]
Daily bump.

5 weeks ago[PATCH 1/3] RISC-V: Improve codegen for negative repeating large constants
Raphael Moreira Zinsly [Wed, 4 Sep 2024 23:21:24 +0000 (17:21 -0600)]
[PATCH 1/3] RISC-V: Improve codegen for negative repeating large constants

Improve handling of constants where its upper and lower 32-bit
halves are the same and have negative values.

e.g. for:

unsigned long f (void) { return 0xf0f0f0f0f0f0f0f0UL; }

Without the patch:

li      a0,-252645376
addi    a0,a0,240
li      a5,-252645376
addi    a5,a5,241
slli    a5,a5,32
add     a0,a5,a0

With the patch:

li      a5,252645376
addi    a5,a5,-241
slli    a0,a5,32
add     a0,a0,a5
xori    a0,a0,-1

gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_split_integer_cost): Adjust the
cost of negative repeating constants.
(riscv_split_integer): Handle negative repeating constants.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/synthesis-11.c: New test.

5 weeks agoCheck DECL_NAMELESS in modified_type_die
Tom Tromey [Thu, 29 Aug 2024 19:23:18 +0000 (13:23 -0600)]
Check DECL_NAMELESS in modified_type_die

While working on a patch to the Ada compiler, I found a spot in
dwarf2out.cc that calls add_name_attribute without respecting
DECL_NAMELESS.

gcc

* dwarf2out.cc (modified_type_die): Check DECL_NAMELESS.

5 weeks ago[RISC-V] Fix scan test output after recent path-splitting changes
Jeff Law [Wed, 4 Sep 2024 18:07:09 +0000 (12:07 -0600)]
[RISC-V] Fix scan test output after recent path-splitting changes

The recent path splitting changes from Andrew result in identifying more
saturation idioms instead of just identifying an overflow check.  As a result
many of the tests in the RISC-V port started failing a scan check on the
.expand output.

As expected, identifying a saturation idiom is more helpful than identifying an
overflow check and the resultant code is better based on my spot checks.

So the right thing to do is to expect more saturation intrinsics in the .expand
output.

I've verified this fixes the regressions for riscv32-elf and riscv64-elf.
Pushing to the trunk.

gcc/testsuite
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-13.c: Adjust
expected output.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-14.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-15.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-16.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-17.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-18.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-19.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-20.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-1.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-2.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-5.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-6.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-9.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-10.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-13.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-14.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-15.c:
Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-9.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-10.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-11.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-12.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-13.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-14.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-15.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-16.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-17.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-18.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-19.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-20.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-21.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-22.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-23.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-24.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-33.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-34.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-35.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-36.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-37.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-38.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-39.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-40.c: Likewise.

5 weeks agoc++: cleanup coerce_template_template_parm
Marek Polacek [Wed, 4 Sep 2024 17:43:52 +0000 (13:43 -0400)]
c++: cleanup coerce_template_template_parm

This function could use some sprucing up.

gcc/cp/ChangeLog:

* pt.cc (coerce_template_template_parm): Return bool instead of int.

5 weeks agoc++: noexcept and pointer to member function type [PR113108]
Marek Polacek [Tue, 3 Sep 2024 17:04:09 +0000 (13:04 -0400)]
c++: noexcept and pointer to member function type [PR113108]

We ICE in nothrow_spec_p because it got a DEFERRED_NOEXCEPT.
This DEFERRED_NOEXCEPT was created in implicitly_declare_fn
when declaring

  Foo& operator=(Foo&&) = default;

in the test.  The problem is that in resolve_overloaded_unification
we call maybe_instantiate_noexcept before try_one_overload only in
the TEMPLATE_ID_EXPR case.

PR c++/113108

gcc/cp/ChangeLog:

* pt.cc (resolve_overloaded_unification): Call
maybe_instantiate_noexcept.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/noexcept-type28.C: New test.

5 weeks agoc++: add a testcase for [PR 108620]
Arsen Arsenović [Tue, 3 Sep 2024 18:58:55 +0000 (20:58 +0200)]
c++: add a testcase for [PR 108620]

Fixed by r15-2540-g32e678b2ed7521.  Add a testcase, as the original ones
do not cover this particular failure mode.

gcc/testsuite/ChangeLog:

PR c++/108620
* g++.dg/coroutines/pr108620.C: New test.

5 weeks agocoros: mark .CO_YIELD as LEAF [PR106973]
Arsen Arsenović [Tue, 3 Sep 2024 15:14:13 +0000 (17:14 +0200)]
coros: mark .CO_YIELD as LEAF [PR106973]

We rely on .CO_YIELD calls being followed by an assignment (optionally)
and then a switch/if in the same basic block.  This implies that a
.CO_YIELD can never end a block.  However, since a call to .CO_YIELD is
still a call, if the function containing it calls setjmp, GCC thinks
that the .CO_YIELD can introduce abnormal control flow, and generates an
edge for the call.

We know this is not the case; .CO_YIELD calls get removed quite early on
and have no effect, and result in no other calls, so .CO_YIELD can be
considered a leaf function, preventing generating an edge when calling
it.

PR c++/106973 - coroutine generator and setjmp

PR c++/106973

gcc/ChangeLog:

* internal-fn.def (CO_YIELD): Mark as ECF_LEAF.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr106973.C: New test.

5 weeks agoobject-size: Use simple_dce_from_worklist in object-size pass
Andrew Pinski [Tue, 3 Sep 2024 19:48:46 +0000 (12:48 -0700)]
object-size: Use simple_dce_from_worklist in object-size pass

While trying to see if there was a way to improve object-size pass
to use the ranger (for pointer plus), I noticed that it leaves around
the statement containing __builtin_object_size if it was reduced to a constant.
This fixes that by using simple_dce_from_worklist.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-object-size.cc (object_sizes_execute): Mark lhs for maybe dceing
if doing a propagate. Call simple_dce_from_worklist.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
5 weeks agoUse dg-additional-options for gfortran.dg/vect/vect-8.f90 and RISC-V
Richard Biener [Wed, 4 Sep 2024 14:00:00 +0000 (16:00 +0200)]
Use dg-additional-options for gfortran.dg/vect/vect-8.f90 and RISC-V

r14-9122-g67a29f99cc8138 disabled scheduling on a lot of testcases
for RISC-V for PR113249 but using dg-options.  This makes
gfortran.dg/vect/vect-8.f90 UNRESOLVED as it relies on default
flags to enable vectorization.

The following uses dg-additional-options instead.

Tested on riscv64-linux with qemu-user, pushed.

I didn't check all the other adjusted tests for similar issues.

* gfortran.dg/vect/vect-8.f90: Use dg-additional-options.

5 weeks agonvptx: Use 'enum ptx_version', 'enum ptx_isa' instead of 'int'
Thomas Schwinge [Mon, 22 Jul 2024 08:49:16 +0000 (10:49 +0200)]
nvptx: Use 'enum ptx_version', 'enum ptx_isa' instead of 'int'

This allows getting rid of the respective type casts.  No change in behavior
intended.

gcc/
* config/nvptx/gen-opt.sh: Use 'enum ptx_isa' instead of 'int'.
* config/nvptx/nvptx-gen.opt: Regenerate.
* config/nvptx/nvptx.opt: Use 'enum ptx_version' instead of 'int'.
* config/nvptx/nvptx-opts.h (enum ptx_isa): Add 'PTX_ISA_unset'.
(enum ptx_version): Add 'PTX_VERSION_unset'.
* config/nvptx/nvptx-c.cc (nvptx_cpu_cpp_builtins): Adjust.
* config/nvptx/nvptx.cc (default_ptx_version_option)
(handle_ptx_version_option, nvptx_option_override)
(nvptx_file_start): Likewise.

5 weeks agoFix branch prediction dump message
Frederik Harwath [Tue, 16 Nov 2021 15:13:51 +0000 (16:13 +0100)]
Fix branch prediction dump message

Instead of, for instance, "Loop got predicted 1 to iterate 10 times"
the message should be "Loop 1 got predicted to iterate 10 times".

gcc/ChangeLog:

* predict.cc (pass_profile::execute): Fix dump message.

Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
5 weeks agoFix gimple_debug_cfg declaration
Frederik Harwath [Tue, 16 Nov 2021 15:08:40 +0000 (16:08 +0100)]
Fix gimple_debug_cfg declaration

Silence a warning. The argument type did not match the definition.

gcc/ChangeLog:

* tree-cfg.h (gimple_debug_cfg): Change argument type from int
to dump_flags_t.

5 weeks agoDocument 'pass_postreload' vs. 'pass_late_compilation'
Thomas Schwinge [Fri, 28 Jun 2024 14:04:18 +0000 (16:04 +0200)]
Document 'pass_postreload' vs. 'pass_late_compilation'

See Subversion r217124 (Git commit 433e4164339f18d0b8798968444a56b681b5232c)
"Reorganize post-ra pipeline for targets without register allocation".

gcc/
* passes.cc: Document 'pass_postreload' vs. 'pass_late_compilation'.
* passes.def: Likewise.

5 weeks agonvptx: Specify '-mno-alias' for 'gcc.dg/pr60797.c' [PR60797, PR104957]
Thomas Schwinge [Sun, 21 Jul 2024 20:23:40 +0000 (22:23 +0200)]
nvptx: Specify '-mno-alias' for 'gcc.dg/pr60797.c' [PR60797, PR104957]

2014 Subversion r209299 (Git commit 8330537b5b58bd0532a0a49f9cbd59bf526a7847)
"Fix PR60797" added this test case, which we now amend so that it's able to
test its thing also in '--target=nvptx-none' configurations with symbol alias
support enabled (..., and test nvptx '-mno-alias').

PR middle-end/60797
PR target/104957
gcc/testsuite/
* gcc.dg/pr60797.c: For nvptx, specify '-mno-alias'.

5 weeks agoAdd 'gcc.target/nvptx/alias-to-alias-1.c'
Thomas Schwinge [Wed, 4 Sep 2024 07:44:33 +0000 (09:44 +0200)]
Add 'gcc.target/nvptx/alias-to-alias-1.c'

... similar to alias to alias usage in 'libgomp.c-c++-common/pr96390.c'.

PR target/104957
gcc/testsuite/
* gcc.target/nvptx/alias-to-alias-1.c: New.

5 weeks agoAdd 'gcc.target/nvptx/alias-weak-1.c'
Thomas Schwinge [Wed, 4 Sep 2024 07:58:32 +0000 (09:58 +0200)]
Add 'gcc.target/nvptx/alias-weak-1.c'

... testing for the GCC/nvptx "weak alias definitions not supported" error
diagnostic (limitation of PTX).

gcc/testsuite/
* gcc.target/nvptx/alias-weak-1.c: New.

5 weeks agorust: avoid clobbering LIBS
Marc Poulhiès [Mon, 5 Aug 2024 15:41:17 +0000 (17:41 +0200)]
rust: avoid clobbering LIBS

Save LIBS around calls to AC_SEARCH_LIBS to avoid clobbering $LIBS.

ChangeLog:

* configure: Regenerate.
* configure.ac: Save LIBS around calls to AC_SEARCH_LIBS.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Reviewed-by: Thomas Schwinge <tschwinge@baylibre.com>
Tested-by: Thomas Schwinge <tschwinge@baylibre.com>
5 weeks agoAlso lower SLP grouped loads with just one consumer
Richard Biener [Mon, 2 Sep 2024 13:00:05 +0000 (15:00 +0200)]
Also lower SLP grouped loads with just one consumer

This makes sure to produce interleaving schemes or load-lanes
for single-element interleaving and other permutes that otherwise
would use more than three vectors.

It exposes the latent issue that single-element interleaving with
large gaps can be inefficient - the mitigation in get_group_load_store_type
doesn't trigger when we clear the load permutation.

It also exposes the fact that not all permutes can be lowered in
the best way in a vector length agnostic way so I've added an
exception to keep power-of-two size contiguous aligned chunks
unlowered (unless we want load-lanes).  The optimal handling
of load/store vectorization is going to continue to be a learning
process.

* tree-vect-slp.cc (vect_lower_load_permutations): Also
process single-use grouped loads.
Avoid lowering contiguous aligned power-of-two sized
chunks, those are better handled by the vector size
specific SLP code generation.
* tree-vect-stmts.cc (get_group_load_store_type): Drop
the unrelated requirement of a load permutation for the
single-element interleaving limit.

* gcc.dg/vect/slp-46.c: Remove XFAIL.

5 weeks agoZen5 tuning part 5: update instruction latencies in x86-tune-costs
Jan Hubicka [Wed, 4 Sep 2024 07:19:08 +0000 (09:19 +0200)]
Zen5 tuning part 5: update instruction latencies in x86-tune-costs

there is nothing exciting in this patch.  I measured latencies and also compared
them with newly released optimization guide.  There are no dramatic changes
compared to zen4.  One interesting new bit is that addss is faster and can be
2 cycles when fed by another addss.

I also increased the large insn bound since decoders seems no longer require
instructions to be 8 bytes or less.

gcc/ChangeLog:

* config/i386/x86-tune-costs.h (znver5_cost): Update instruction
costs.

5 weeks agoexpand: Add dump for costing of positive divides
Andrew Pinski [Wed, 4 Sep 2024 01:50:37 +0000 (18:50 -0700)]
expand: Add dump for costing of positive divides

While trying to understand PR 115910 I found it was useful to print out
the two costs of doing a signed and unsigned division just like was added in
r15-3272-g3c89c41991d8e8 for popcount==1.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* expr.cc (expand_expr_divmod): Add dump of the two costs for
positive division.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
5 weeks agoCRIS: Add new peephole2 "lra_szext_decomposed_indir_plus"
Hans-Peter Nilsson [Mon, 8 Jul 2024 01:59:55 +0000 (03:59 +0200)]
CRIS: Add new peephole2 "lra_szext_decomposed_indir_plus"

Exposed when running the test-suite with -flate-combine-instructions.

* config/cris/cris.md (lra_szext_decomposed_indir_plus): New
peephole2 pattern.

5 weeks agoRISC-V: Allow IMM operand for unsigned scalar .SAT_ADD
Pan Li [Mon, 2 Sep 2024 07:54:43 +0000 (15:54 +0800)]
RISC-V: Allow IMM operand for unsigned scalar .SAT_ADD

This patch would like to allow the IMM operand of the unsigned
scalar .SAT_ADD.  Like the operand 0, the operand 1 of .SAT_ADD
will be zero extended to Xmode before underlying code generation.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_expand_usadd): Zero extend
the second operand of usadd as the first operand does.
* config/riscv/riscv.md (usadd<m>3): Allow imm operand for
scalar usadd pattern.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_u_add-11.c: Make asm check robust.
* gcc.target/riscv/sat_u_add-15.c: Ditto.
* gcc.target/riscv/sat_u_add-19.c: Ditto.
* gcc.target/riscv/sat_u_add-23.c: Ditto.
* gcc.target/riscv/sat_u_add-3.c: Ditto.
* gcc.target/riscv/sat_u_add-7.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 weeks agoaarch64: Fix testcase vec-init-22-speed.c [PR116589]
Andrew Pinski [Wed, 4 Sep 2024 00:10:37 +0000 (17:10 -0700)]
aarch64: Fix testcase vec-init-22-speed.c [PR116589]

For this testcase, the trunk produces:
```
f_s16:
        fmov    s31, w0
        fmov    s0, w1
```

While the testcase was expecting what was produced in GCC 14:
```
f_s16:
        sxth    w0, w0
        sxth    w1, w1
        fmov    d31, x0
        fmov    d0, x1
```

After r15-1575-gea8061f46a30 the code was:
```
        dup     v31.4h, w0
        dup     v0.4h, w1
```
But when ext-dce was added with r15-1901-g98914f9eba5f19, we get the better code generation now and only fmov's.

Pushed as obvious after running the testcase.

PR target/116589

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/vec-init-22-speed.c: Update scan for better code gen.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
5 weeks agosplit-path: Improve ifcvt heurstic for split path [PR112402]
Andrew Pinski [Tue, 3 Sep 2024 04:34:53 +0000 (21:34 -0700)]
split-path: Improve ifcvt heurstic for split path [PR112402]

This simplifies the heurstic for split path to see if the join
bb is a ifcvt candidate.
For the predecessors bbs need either to be empty or only have one
statement in them which could be a decent ifcvt candidate.
The previous heurstics would miss that:
```
if (a) goto B else goto C;
B:  goto C;
C:
c = PHI<d,e>
```

Would be a decent ifcvt candidate. And would also miss:
```
if (a) goto B else goto C;
B: d = f + 1;  goto C;
C:
c = PHI<d,e>
```

Also since currently the max number of cmovs being able to produced is 3, we
should only assume `<= 3` phis can be ifcvt candidates.

The testcase changes for split-path-6.c is that lookharder function
is a true ifcvt case where we would get cmov as expected; it looks like it
was not a candidate when the heurstic was added but became one later on.
pr88797.C is now rejected via it being an ifcvt candidate rather than being about
DCE/const prop.

The rest of the testsuite changes are just slight change in the dump,
removing the "*diamnond" part as it was removed from the print.

Bootstrapped and tested on x86_64.

PR tree-optimization/112402

gcc/ChangeLog:

* gimple-ssa-split-paths.cc (poor_ifcvt_pred): New function.
(is_feasible_trace): Remove old heurstics for ifcvt cases.
For num_stmts <=1 for both pred check poor_ifcvt_pred on both
pred.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/split-path-11.c: Update scan.
* gcc.dg/tree-ssa/split-path-2.c: Update scan.
* gcc.dg/tree-ssa/split-path-5.c: Update scan.
* gcc.dg/tree-ssa/split-path-6.c: Update scan.
* g++.dg/tree-ssa/pr88797.C: Update scan.
* gcc.dg/tree-ssa/split-path-13.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
5 weeks agosplit-paths: Move check for # of statements in join earlier
Andrew Pinski [Tue, 3 Sep 2024 03:38:11 +0000 (20:38 -0700)]
split-paths: Move check for # of statements in join earlier

This moves the check for # of statements to copy in join to
be the first check. This check is the cheapest check so it
should be first. Plus add a print to the dump file since there
was none beforehand.

gcc/ChangeLog:

* gimple-ssa-split-paths.cc (is_feasible_trace): Move
check for # of statments in join earlier and add a
debug print.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
5 weeks agoExplicitly document that the "counted_by" attribute is only supported in C.
Qing Zhao [Tue, 3 Sep 2024 19:28:23 +0000 (19:28 +0000)]
Explicitly document that the "counted_by" attribute is only supported in C.

The "counted_by" attribute currently is only supported in C, mention this
explicitly in documentation and also issue warnings when see "counted_by"
attribute in C++ with -Wattributes.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_counted_by_attribute): Is ignored and issues
warning with -Wattributes in C++ for now.

gcc/ChangeLog:

* doc/extend.texi: Explicitly mentions counted_by is available
only in C for now.

gcc/testsuite/ChangeLog:

* g++.dg/ext/flex-array-counted-by.C: New test.
* g++.dg/ext/flex-array-counted-by-2.C: New test.

5 weeks agoc++: support C++11 attributes in C++98
Jason Merrill [Fri, 30 Aug 2024 20:02:10 +0000 (16:02 -0400)]
c++: support C++11 attributes in C++98

I don't see any reason why we can't allow the [[]] attribute syntax in C++98
mode with a pedwarn just like many other C++11 features.  In fact, we
already do support it in some places in the grammar, but not in places that
check cp_nth_tokens_can_be_std_attribute_p.

Let's also follow the C front-end's lead in only warning about them when
-pedantic.

It still isn't necessary for this function to guard against Objective-C
message passing syntax; we handle that with tentative parsing in
cp_parser_statement, and we don't call this function in that context anyway.

gcc/cp/ChangeLog:

* parser.cc (cp_nth_tokens_can_be_std_attribute_p): Don't check
cxx_dialect.
* error.cc (maybe_warn_cpp0x): Only complain about C++11 attributes
if pedantic.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/gen-attrs-1.C: Also run in C++98 mode.
* g++.dg/cpp0x/gen-attrs-11.C: Likewise.
* g++.dg/cpp0x/gen-attrs-13.C: Likewise.
* g++.dg/cpp0x/gen-attrs-15.C: Likewise.
* g++.dg/cpp0x/gen-attrs-75.C: Don't expect C++98 warning after
__extension__.

5 weeks agoPR116080: Fix test suite checks for musttail
Andi Kleen [Mon, 29 Jul 2024 17:58:29 +0000 (10:58 -0700)]
PR116080: Fix test suite checks for musttail

This is a new attempt to fix PR116080. The previous try was reverted
because it just broke a bunch of tests, hiding the problem.

- musttail behaves differently than tailcall at -O0. Some of the test
run at -O0, so add separate effective target tests for musttail.
- New effective target tests need to use unique file names
to make dejagnu caching work
- Change the tests to use new targets
- Add a external_musttail test to check for target's ability
to do tail calls between translation units. This covers some powerpc
ABIs.

gcc/testsuite/ChangeLog:

PR testsuite/116080
* c-c++-common/musttail1.c: Use musttail target.
* c-c++-common/musttail12.c: Use struct_musttail target.
* c-c++-common/musttail2.c: Use musttail target.
* c-c++-common/musttail3.c: Likewise.
* c-c++-common/musttail4.c: Likewise.
* c-c++-common/musttail7.c: Likewise.
* c-c++-common/musttail8.c: Likewise.
* g++.dg/musttail10.C: Likewise. Replace powerpc checks with
external_musttail.
* g++.dg/musttail11.C: Use musttail target.
* g++.dg/musttail6.C: Use musttail target. Replace powerpc
checks with external_musttail.
* g++.dg/musttail9.C: Use musttail target.
* lib/target-supports.exp: Add musttail, struct_musttail,
external_musttail targets. Remove optimization for musttail.
Use unique file names for musttail.

5 weeks agopretty-print: split up pretty_printer::format into subroutines
David Malcolm [Tue, 3 Sep 2024 19:11:06 +0000 (15:11 -0400)]
pretty-print: split up pretty_printer::format into subroutines

The body of pretty_printer::format is almost 500 lines long,
mostly comprising two distinct phases.

This patch splits it up so that there are explicit subroutines
for the two different phases, reducing the scope of various
locals, and making it easier to e.g. put a breakpoint on phase 2.

No functional change intended.

gcc/ChangeLog:
* pretty-print-markup.h (pp_markup::context::context): Drop
params "buf" and "chunk_idx", initializing m_buf from pp.
(pp_markup::context::m_chunk_idx): Drop field.
* pretty-print.cc (pretty_printer::format): Convert param
from a text_info * to a text_info &.  Split out phase 1
and phase 2 into subroutines...
(format_phase_1): New, from pretty_printer::format.
(format_phase_2): Likewise.
* pretty-print.h (pretty_printer::format): Convert param
from a text_info * to a text_info &.
(pp_format): Update for above change.  Assert that text_info is
non-null.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
5 weeks agopretty-print: add selftest of pp_format's stack
David Malcolm [Tue, 3 Sep 2024 19:11:01 +0000 (15:11 -0400)]
pretty-print: add selftest of pp_format's stack

gcc/ChangeLog:
* pretty-print-format-impl.h (pp_formatted_chunks::get_prev): New
accessor.
* pretty-print.cc (selftest::push_pp_format): New.
(ASSERT_TEXT_TOKEN): New macro.
(selftest::test_pp_format_stack): New test.
(selftest::pretty_print_cc_tests): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This page took 0.13738 seconds and 5 git commands to generate.