]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agoOpenMP/C++: Fix (first)private clause with member variables [PR110347] devel/omp/gcc-13
Jakub Jelinek [Mon, 4 Mar 2024 11:55:27 +0000 (12:55 +0100)] 
OpenMP/C++: Fix (first)private clause with member variables [PR110347]

OpenMP permits '(first)private' for C++ member variables, which GCC handles
by tagging those by DECL_OMP_PRIVATIZED_MEMBER, adding a temporary VAR_DECL
and DECL_VALUE_EXPR pointing to the 'this->member_var' in the C++ front end.

The idea is that in omp-low.cc, the DECL_VALUE_EXPR is used before the
region (for 'firstprivate'; ignored for 'private') while in the region,
the DECL itself is used.

In gimplify, the value expansion is suppressed and deferred if the
  lang_hooks.decls.omp_disregard_value_expr (decl, shared)
returns true - which is never the case if 'shared' is true. In OpenMP 4.5,
only 'map' and 'use_device_ptr' was permitted for the 'target' directive.
And when OpenMP 5.0's 'private'/'firstprivate' clauses was added, the
the update that now 'shared' argument could be false was missed. The
respective check has now been added.

2024-03-01  Jakub Jelinek  <jakub@redhat.com>
    Tobias Burnus  <tburnus@baylibre.com>

PR c++/110347

gcc/ChangeLog:

* gimplify.cc (omp_notice_variable): Fix 'shared' arg to
lang_hooks.decls.omp_disregard_value_expr for
(first)private in target regions.

libgomp/ChangeLog:

* testsuite/libgomp.c++/target-lambda-3.C: Moved from
gcc/testsuite/g++.dg/gomp/ and fixed is-mapped handling.
* testsuite/libgomp.c++/target-lambda-1.C: Modify to also
also work without offloading.
* testsuite/libgomp.c++/firstprivate-1.C: New test.
* testsuite/libgomp.c++/firstprivate-2.C: New test.
* testsuite/libgomp.c++/private-1.C: New test.
* testsuite/libgomp.c++/private-2.C: New test.
* testsuite/libgomp.c++/target-lambda-4.C: New test.
* testsuite/libgomp.c++/use_device_ptr-1.C: New test.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/target-lambda-1.C: Moved to become a
run-time test under testsuite/libgomp.c++.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
(cherry picked from commit 4f82d5a95a244d0aa4f8b2541b47a21bce8a191b)

4 months ago[OpenACC] Add tests for implied copy of variables in reduction clause.
Hafiz Abid Qadeer [Wed, 20 Dec 2023 13:50:26 +0000 (13:50 +0000)] 
[OpenACC] Add tests for implied copy of variables in reduction clause.

The OpenACC reduction clause on compute construct implies a copy clause
for each reduction variable [1]. This patch adds tests to check if the
implied copy is being generated. The check covers various types and
operators as described in the specification.

gcc/testsuite/ChangeLog:

* c-c++-common/goacc/implied-copy-1.c: New test.
* c-c++-common/goacc/implied-copy-2.c: New test.
* g++.dg/goacc/implied-copy.C: New test.
* gcc.dg/goacc/implied-copy.c: New test.
* gfortran.dg/goacc/implied-copy-1.f90: New test.
* gfortran.dg/goacc/implied-copy-2.f90: New test.

[1] OpenACC 2.7 Specification section 2.5.13

5 months agoFortran: fix reallocation on assignment of polymorphic variables [PR110415]
Andrew Jenner [Tue, 28 Nov 2023 15:27:05 +0000 (15:27 +0000)] 
Fortran: fix reallocation on assignment of polymorphic variables [PR110415]

This patch fixes two bugs related to polymorphic class assignment in the
Fortran front-end. One (described in PR110415) is an issue with the malloc
and realloc calls using the size from the old vptr rather than the new one.
The other is caused by the return value from the realloc call being ignored.
Testcases are added for these issues.

2023-11-28  Andrew Jenner  <andrew@codesourcery.com>

gcc/fortran/
PR fortran/110415
* trans-expr.cc (trans_class_vptr_len_assignment): Add
from_vptrp parameter. Populate it. Don't check for DECL_P
when deciding whether to create temporary.
(trans_class_pointer_fcn, gfc_trans_pointer_assignment): Add
NULL argument to trans_class_vptr_len_assignment calls.
(trans_class_assignment): Get rhs_vptr from
trans_class_vptr_len_assignment and use it for determining size
for allocation/reallocation. Use return value from realloc.

gcc/testsuite/
PR fortran/110415
* gfortran.dg/pr110415.f90: New test.
* gfortran.dg/asan/pr110415-2.f90: New test.
* gfortran.dg/asan/pr110415-3.f90: New test.

Co-Authored-By: Tobias Burnus <tobias@codesourcery.com>
5 months agoamdgcn: Disallow TImode vector permute
Andrew Stubbs [Fri, 10 Nov 2023 16:07:25 +0000 (16:07 +0000)] 
amdgcn: Disallow TImode vector permute

We don't support it and it doesn't happen without vector extensions, so
just remove the unhandled case.

Fixes gcc.dg/pr78575.c failure.

gcc/ChangeLog:

* config/gcn/gcn.cc (gcn_vectorize_vec_perm_const): Disallow TImode.

(cherry picked from commit e7d3414dffc98efc8424818dedac138c99c9ca79)

5 months agoamdgcn: Fix vector TImode reload loop
Andrew Stubbs [Wed, 22 Nov 2023 13:46:12 +0000 (13:46 +0000)] 
amdgcn: Fix vector TImode reload loop

I've only observed the problem on the devel/omp/gcc-13 branch, but this
could theoretically affect mainline also.  The mov insns for the other modes
already have '$', so this completes the set.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (*mov<mode>_4reg): Disparage AVGPR use when a
reload is required.

(cherry picked from commit ecb22ddbe2b676484d04e7979f7991f7eec93470)

5 months agoamdgcn: Add Accelerator VGPR registers
Andrew Stubbs [Tue, 3 Oct 2023 13:03:49 +0000 (14:03 +0100)] 
amdgcn: Add Accelerator VGPR registers

Add the new CDNA register file.  We don't support any of the specialized
instructions that use these registers, but they're useful to relieve
register pressure without spilling to stack.

Co-authored-by: Andrew Jenner <andrew@codesourcery.com>
gcc/ChangeLog:

* config/gcn/constraints.md: Add "a" AVGPR constraint.
* config/gcn/gcn-valu.md (*mov<mode>): Add AVGPR alternatives.
(*mov<mode>_4reg): Likewise.
(@mov<mode>_sgprbase): Likewise.
(gather<mode>_insn_1offset<exec>): Likewise.
(gather<mode>_insn_1offset_ds<exec>): Likewise.
(gather<mode>_insn_2offsets<exec>): Likewise.
(scatter<mode>_expr<exec_scatter>): Likewise.
(scatter<mode>_insn_1offset_ds<exec_scatter>): Likewise.
(scatter<mode>_insn_2offsets<exec_scatter>): Likewise.
* config/gcn/gcn.cc (MAX_NORMAL_AVGPR_COUNT): Define.
(gcn_class_max_nregs): Handle AVGPR_REGS and ALL_VGPR_REGS.
(gcn_hard_regno_mode_ok): Likewise.
(gcn_regno_reg_class): Likewise.
(gcn_spill_class): Allow spilling to AVGPRs on TARGET_CDNA1_PLUS.
(gcn_sgpr_move_p): Handle AVGPRs.
(gcn_secondary_reload): Reload AVGPRs via VGPRs.
(gcn_conditional_register_usage): Handle AVGPRs.
(gcn_vgpr_equivalent_register_operand): New function.
(gcn_valid_move_p): Check for validity of AVGPR moves.
(gcn_compute_frame_offsets): Handle AVGPRs.
(gcn_memory_move_cost): Likewise.
(gcn_register_move_cost): Likewise.
(gcn_vmem_insn_p): Handle TYPE_VOP3P_MAI.
(gcn_md_reorg): Handle AVGPRs.
(gcn_hsa_declare_function_name): Likewise.
(print_reg): Likewise.
(gcn_dwarf_register_number): Likewise.
* config/gcn/gcn.h (FIRST_AVGPR_REG): Define.
(AVGPR_REGNO): Define.
(LAST_AVGPR_REG): Define.
(SOFT_ARG_REG): Update.
(FRAME_POINTER_REGNUM): Update.
(DWARF_LINK_REGISTER): Update.
(FIRST_PSEUDO_REGISTER): Update.
(AVGPR_REGNO_P): Define.
(enum reg_class): Add AVGPR_REGS and ALL_VGPR_REGS.
(REG_CLASS_CONTENTS): Add new register classes and add entries for
AVGPRs to all classes.
(REGISTER_NAMES): Add AVGPRs.
* config/gcn/gcn.md (FIRST_AVGPR_REG, LAST_AVGPR_REG): Define.
(AP_REGNUM, FP_REGNUM): Update.
(define_attr "type"): Add vop3p_mai.
(define_attr "unit"): Handle vop3p_mai.
(define_attr "gcn_version"): Add "cdna2".
(define_attr "enabled"): Handle cdna2.
(*mov<mode>_insn): Add AVGPR alternatives.
(*movti_insn): Likewise.
* config/gcn/mkoffload.cc (isa_has_combined_avgprs): New.
(process_asm): Process avgpr_count.
* config/gcn/predicates.md (gcn_avgpr_register_operand): New.
(gcn_avgpr_hard_register_operand): New.
* doc/md.texi: Document the "a" constraint.

gcc/testsuite/ChangeLog:

* gcc.target/gcn/avgpr-mem-double.c: New test.
* gcc.target/gcn/avgpr-mem-int.c: New test.
* gcc.target/gcn/avgpr-mem-long.c: New test.
* gcc.target/gcn/avgpr-mem-short.c: New test.
* gcc.target/gcn/avgpr-spill-double.c: New test.
* gcc.target/gcn/avgpr-spill-int.c: New test.
* gcc.target/gcn/avgpr-spill-long.c: New test.
* gcc.target/gcn/avgpr-spill-short.c: New test.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (max_isa_vgprs): New.
(run_kernel): CDNA2 devices have more VGPRs.

(cherry picked from commit ae0d2c240213c5a7f6959c032bfc9f0703cab787)

5 months agoamdgcn: simplify secondary reload patterns
Andrew Stubbs [Fri, 6 Oct 2023 10:14:05 +0000 (11:14 +0100)] 
amdgcn: simplify secondary reload patterns

Remove some unnecessary complexity; no functional change is intended,
although LRA appears to use the constraints from the reload_in/out
patterns, so it's probably an improvement for it to see the real sgprbase
constraints.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (mov<mode>_sgprbase): Add @ modifier.
(reload_in<mode>): Delete.
(reload_out<mode>): Delete.
* config/gcn/gcn.cc (CODE_FOR): Delete.
(get_code_for_##PREFIX##vN##SUFFIX): Delete.
(CODE_FOR_OP): Delete.
(get_code_for_##PREFIX): Delete.
(gcn_secondary_reload): Replace "get_code_for" with "code_for".

(cherry picked from commit a0e6306b7ee16ce4ef067c00609d1303fed71c74)

6 months agoamdgcn: Fix vector min/max ICE
Andrew Stubbs [Fri, 10 Nov 2023 09:43:21 +0000 (09:43 +0000)] 
amdgcn: Fix vector min/max ICE

The DImode min/max instructions need a clobber that SImode does not, so
add the special case to the reduction expand code.

gcc/ChangeLog:

* config/gcn/gcn.cc (gcn_expand_reduc_scalar): Add clobber to DImode
min/max instructions.

6 months agoamdgcn: silence warnings
Andrew Stubbs [Fri, 27 Oct 2023 10:37:07 +0000 (11:37 +0100)] 
amdgcn: silence warnings

The operands really should be VOIDmode, so the warnings are false.

gcc/ChangeLog:

* config/gcn/gcn-valu.md
(vec_extract<V_1REG:mode><V_1REG_ALT:mode>_nop): Mention "operands" in
condition to silence the warnings.
(vec_extract<V_2REG:mode><V_2REG_ALT:mode>_nop): Likewise.
* config/gcn/gcn.md (*movti_insn): Likewise.

6 months agoamdgcn: switch mov insns to compact syntax
Andrew Stubbs [Mon, 2 Oct 2023 10:42:03 +0000 (11:42 +0100)] 
amdgcn: switch mov insns to compact syntax

The move instructions typically have many alternatives (and I'm about to add
more) so are good candidates for the new syntax.

This patch only converts the patterns where there are no significant changes to
the generated files. The other patterns can be converted another time.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (*mov<mode>): Convert to compact syntax.
(mov<mode>_exec): Likewise.
(mov<mode>_sgprbase): Likewise.
* config/gcn/gcn.md (*mov<mode>_insn): Likewise.
(*movti_insn): Likewise.

(cherry picked from commit ddfa43933ebc9e6508f0df9e748a765a74e01809)

6 months agoamdgcn: silence warning
Andrew Stubbs [Fri, 29 Sep 2023 14:45:30 +0000 (15:45 +0100)] 
amdgcn: silence warning

gcc/ChangeLog:

* config/gcn/gcn.cc (print_operand): Adjust xcode type to fix warning.

(cherry picked from commit eb239c7f22b646873e93f8115ee992c4fb4d878a)

6 months agoNew compact syntax for insn and insn_split in Machine Descriptions.
Tamar Christina [Mon, 19 Jun 2023 14:47:46 +0000 (15:47 +0100)] 
New compact syntax for insn and insn_split in Machine Descriptions.

This patch adds support for a compact syntax for specifying constraints in
instruction patterns. Credit for the idea goes to Richard Earnshaw.

With this new syntax we want a clean break from the current limitations to make
something that is hopefully easier to use and maintain.

The idea behind this compact syntax is that often times it's quite hard to
correlate the entries in the constrains list, attributes and instruction lists.

One has to count and this often is tedious.  Additionally when changing a single
line in the insn multiple lines in a diff change, making it harder to see what's
going on.

This new syntax takes into account many of the common things that are done in MD
files.   It's also worth saying that this version is intended to deal with the
common case of a string based alternatives.   For C chunks we have some ideas
but those are not intended to be addressed here.

It's easiest to explain with an example:

normal syntax:

(define_insn_and_split "*movsi_aarch64"
  [(set (match_operand:SI 0 "nonimmediate_operand" "=r,k,r,r,r,r, r,w, m, m,  r,  r,  r, w,r,w, w")
(match_operand:SI 1 "aarch64_mov_operand"  " r,r,k,M,n,Usv,m,m,rZ,w,Usw,Usa,Ush,rZ,w,w,Ds"))]
  "(register_operand (operands[0], SImode)
    || aarch64_reg_or_zero (operands[1], SImode))"
  "@
   mov\\t%w0, %w1
   mov\\t%w0, %w1
   mov\\t%w0, %w1
   mov\\t%w0, %1
   #
   * return aarch64_output_sve_cnt_immediate (\"cnt\", \"%x0\", operands[1]);
   ldr\\t%w0, %1
   ldr\\t%s0, %1
   str\\t%w1, %0
   str\\t%s1, %0
   adrp\\t%x0, %A1\;ldr\\t%w0, [%x0, %L1]
   adr\\t%x0, %c1
   adrp\\t%x0, %A1
   fmov\\t%s0, %w1
   fmov\\t%w0, %s1
   fmov\\t%s0, %s1
   * return aarch64_output_scalar_simd_mov_immediate (operands[1], SImode);"
  "CONST_INT_P (operands[1]) && !aarch64_move_imm (INTVAL (operands[1]), SImode)
    && REG_P (operands[0]) && GP_REGNUM_P (REGNO (operands[0]))"
   [(const_int 0)]
   "{
       aarch64_expand_mov_immediate (operands[0], operands[1]);
       DONE;
    }"
  ;; The "mov_imm" type for CNT is just a placeholder.
  [(set_attr "type" "mov_reg,mov_reg,mov_reg,mov_imm,mov_imm,mov_imm,load_4,
    load_4,store_4,store_4,load_4,adr,adr,f_mcr,f_mrc,fmov,neon_move")
   (set_attr "arch"   "*,*,*,*,*,sve,*,fp,*,fp,*,*,*,fp,fp,fp,simd")
   (set_attr "length" "4,4,4,4,*,  4,4, 4,4, 4,8,4,4, 4, 4, 4,   4")
]
)

New syntax:

(define_insn_and_split "*movsi_aarch64"
  [(set (match_operand:SI 0 "nonimmediate_operand")
(match_operand:SI 1 "aarch64_mov_operand"))]
  "(register_operand (operands[0], SImode)
    || aarch64_reg_or_zero (operands[1], SImode))"
  {@ [cons: =0, 1; attrs: type, arch, length]
     [r , r  ; mov_reg  , *   , 4] mov\t%w0, %w1
     [k , r  ; mov_reg  , *   , 4] ^
     [r , k  ; mov_reg  , *   , 4] ^
     [r , M  ; mov_imm  , *   , 4] mov\t%w0, %1
     [r , n  ; mov_imm  , *   ,16] #
     /* The "mov_imm" type for CNT is just a placeholder.  */
     [r , Usv; mov_imm  , sve , 4] << aarch64_output_sve_cnt_immediate ("cnt", "%x0", operands[1]);
     [r , m  ; load_4   , *   , 4] ldr\t%w0, %1
     [w , m  ; load_4   , fp  , 4] ldr\t%s0, %1
     [m , rZ ; store_4  , *   , 4] str\t%w1, %0
     [m , w  ; store_4  , fp  , 4] str\t%s1, %0
     [r , Usw; load_4   , *   , 8] adrp\t%x0, %A1;ldr\t%w0, [%x0, %L1]
     [r , Usa; adr      , *   , 4] adr\t%x0, %c1
     [r , Ush; adr      , *   , 4] adrp\t%x0, %A1
     [w , rZ ; f_mcr    , fp  , 4] fmov\t%s0, %w1
     [r , w  ; f_mrc    , fp  , 4] fmov\t%w0, %s1
     [w , w  ; fmov     , fp  , 4] fmov\t%s0, %s1
     [w , Ds ; neon_move, simd, 4] << aarch64_output_scalar_simd_mov_immediate (operands[1], SImode);
  }
  "CONST_INT_P (operands[1]) && !aarch64_move_imm (INTVAL (operands[1]), SImode)
    && REG_P (operands[0]) && GP_REGNUM_P (REGNO (operands[0]))"
  [(const_int 0)]
  {
    aarch64_expand_mov_immediate (operands[0], operands[1]);
    DONE;
  }
)

The main syntax rules are as follows (See docs for full rules):
  - Template must start with "{@" and end with "}" to use the new syntax.
  - "{@" is followed by a layout in parentheses which is "cons:" followed by
    a list of match_operand/match_scratch IDs, then a semicolon, then the
    same for attributes ("attrs:"). Both sections are optional (so you can
    use only cons, or only attrs, or both), and cons must come before attrs
    if present.
  - Each alternative begins with any amount of whitespace.
  - Following the whitespace is a comma-separated list of constraints and/or
    attributes within brackets [], with sections separated by a semicolon.
  - Following the closing ']' is any amount of whitespace, and then the actual
    asm output.
  - Spaces are allowed in the list (they will simply be removed).
  - All alternatives should be specified: a blank list should be
    "[,,]", "[,,;,]" etc., not "[]" or "" (however genattr may segfault if
    you leave certain attributes empty, I have found).
  - The actual constraint string in the match_operand or match_scratch, and
    the attribute string in the set_attr, must be blank or an empty string
    (you can't combine the old and new syntaxes).
  - The common idion * return can be shortened by using <<.
  - Any unexpanded iterators left during processing will result in an error at
    compile time.   If for some reason <> is needed in the output then these
    must be escaped using \.
  - Within an {@ block both multiline and singleline C comments are allowed, but
    when used outside of a C block they must be the only non-whitespace blocks on
    the line
  - Inside an {@ block any unexpanded iterators will result in a compile time
    fault instead of incorrect assembly being generated at runtime.  If the
    literal <> is needed in the output this needs to be escaped with \<\>.
  - This check is not performed inside C blocks (lines starting with *).
  - Instead of copying the previous instruction again in the next pattern, one
    can use ^ to refer to the previous asm string.

This patch works by blindly transforming the new syntax into the old syntax,
so it doesn't do extensive checking. However, it does verify that:
- The correct number of constraints/attributes are specified.
- You haven't mixed old and new syntax.
- The specified operand IDs/attribute names actually exist.
- You don't have duplicate cons

If something goes wrong, it may write invalid constraints/attributes/template
back into the rtx. But this shouldn't matter because error_at will cause the
program to fail on exit anyway.

Because this transformation occurs as early as possible (before patterns are
queued), the rest of the compiler can completely ignore the new syntax and
assume that the old syntax will always be used.

This doesn't seem to have any measurable effect on the runtime of gen*
programs.

gcc/ChangeLog:

* gensupport.cc (class conlist, add_constraints, add_attributes,
skip_spaces, expect_char, preprocess_compact_syntax,
parse_section_layout, parse_section, convert_syntax): New.
(process_rtx): Check for conversion.
* genoutput.cc (process_template): Check for unresolved iterators.
(class data): Add compact_syntax_p.
(gen_insn): Use it.
* gensupport.h (compact_syntax): New.
(hash-set.h): Include.
* doc/md.texi: Document it.

Co-Authored-By: Omar Tahir <Omar.Tahir2@arm.com>
(cherry picked from commit 957ae90406591739b68e95ad49a0232faeb74217)

6 months agoOpenMP/Fortran: Fix parsing of metadirectives with BLOCK
Tobias Burnus [Tue, 31 Oct 2023 11:03:44 +0000 (12:03 +0100)] 
OpenMP/Fortran: Fix parsing of metadirectives with BLOCK

Probably a fallout of the backport of r14-4471-g6a8edd50a149f1
  Fortran/OpenMP: Fix handling of strictly structured blocks
This showed up as parsing error/fail with
 libgomp.fortran/metadirective-1.f90
 libgomp.fortran/metadirective-6.f90

gcc/fortran/

* decl.cc (gfc_match_end): Handle unnamed END BLOCK with
metadirectives.

6 months agoOpenMP/Fortran: Ensure allocator is gimplified for 'omp allocate'
Tobias Burnus [Mon, 30 Oct 2023 09:53:29 +0000 (10:53 +0100)] 
OpenMP/Fortran: Ensure allocator is gimplified for 'omp allocate'

Without this change, we we get an ICE in verify_gimple_call for
GOMP_allocate when doing a late replacement in omp-low.cc

gcc/fortran/ChangeLog:

       * trans-openmp.cc (gfc_trans_omp_clauses): Avoid gfc_evaluate_now
       for allocator with indirect ref for better diagnostic.

gcc/ChangeLog:

* gcc/gimplify.cc (gimplify_omp_allocate): Gimplify allocator.
* omp-low.cc (lower_omp_allocate): Simplify; GOMP_free can also
take a plain 0 as allocator argument (arg is unused in libgomp).

libgomp/ChangeLog:

* testsuite/libgomp.fortran/allocate-8a.f90: New test.

6 months agoOpenMP: Avoid ICE with LTO and 'omp allocate'
Tobias Burnus [Fri, 27 Oct 2023 10:41:31 +0000 (12:41 +0200)] 
OpenMP: Avoid ICE with LTO and 'omp allocate'

gcc/ChangeLog:

* gimplify.cc (gimplify_bind_expr): Remove "omp allocate" attribute
to avoid that auxillary statement list reaches LTO.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/allocate-13a.f90: New test.

(cherry picked from commit af4bb221153359f5948da917d5ef2df738bb1e61)

6 months agogfortran.dg/gomp/allocate-4a.f90: Update dg-error
Tobias Burnus [Thu, 26 Oct 2023 14:12:19 +0000 (16:12 +0200)] 
gfortran.dg/gomp/allocate-4a.f90: Update dg-error

This has been missed to include in commit
  59175e6f088 Fortran: Support OpenMP's 'allocate' directive for stack vars

gcc/testsuite/

        * gfortran.dg/gomp/allocate-4a.f90: Update dg-error.

6 months agoOpenMP: Add C++ support for 'omp allocate' with stack variables
Tobias Burnus [Thu, 26 Oct 2023 10:05:26 +0000 (12:05 +0200)] 
OpenMP: Add C++ support for 'omp allocate' with stack variables

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_allocate): Change error
wording.

gcc/cp/ChangeLog:

* cp-tree.h (finish_omp_allocate): New prototype.
* parser.cc (struct cp_omp_loc_tree,
cp_check_omp_allocate_allocator_r): New.
(cp_parser_omp_allocate): Call it; remove sorry,
improve checks, call finish_omp_allocate.
* pt.cc (tsubst_stmt): Call finish_omp_allocate.
* semantics.cc (finish_omp_allocate): New.

libgomp/ChangeLog:

* libgomp.texi (OpenMP Impl. Status): Document that 'omp allocate'
is now supported for C++ stack/automatic variables.
* testsuite/libgomp.c-c++-common/allocate-4.c: Renamed from ...
* testsuite/libgomp.c/allocate-4.c: ... this.
* testsuite/libgomp.c-c++-common/allocate-5.c: Renamed from ...
* testsuite/libgomp.c/allocate-5.c: ... this.
* testsuite/libgomp.c-c++-common/allocate-6.c: Renamed from ...
* testsuite/libgomp.c/allocate-6.c: ... this.
* testsuite/libgomp.c++/allocate-2.C: New test.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/allocate-5.c: Remove C++ 'sorry'; minor updates.
* c-c++-common/gomp/allocate-9.c: Likewise.
* c-c++-common/gomp/allocate-17.c: Likewise.
* c-c++-common/gomp/directive-1.c: Likewise.
* g++.dg/gomp/allocate-5.C: New test.

6 months agoFortran: Support OpenMP's 'allocate' directive for stack vars
Tobias Burnus [Thu, 26 Oct 2023 09:52:15 +0000 (11:52 +0200)] 
Fortran: Support OpenMP's 'allocate' directive for stack vars

gcc/fortran/ChangeLog:

* gfortran.h (ext_attr_t): Add omp_allocate flag.
* match.cc (gfc_free_omp_namelist): Void deleting same
u2.allocator multiple times now that a sequence can use
the same one.
* openmp.cc (gfc_match_omp_clauses, gfc_match_omp_allocate): Use
same allocator expr multiple times.
(is_predefined_allocator): Make static.
(gfc_resolve_omp_allocate): Update/extend restriction checks;
remove sorry message.
(resolve_omp_clauses): Reject corarrays in allocate/allocators
directive.
* parse.cc (check_omp_allocate_stmt): Permit procedure pointers
here (rejected later) for less misleading diagnostic.
* trans-array.cc (gfc_trans_auto_array_allocation): Propagate
size for GOMP_alloc and location to which it should be added to.
* trans-decl.cc (gfc_trans_deferred_vars): Handle 'omp allocate'
for stack variables; sorry for static variables/common blocks.
* trans-openmp.cc (gfc_trans_omp_clauses): Evaluate 'allocate'
clause's allocator only once; fix adding expressions to the
block.
(gfc_trans_omp_single): Pass a block to gfc_trans_omp_clauses.

gcc/ChangeLog:

* gimplify.cc (gimplify_bind_expr): Handle Fortran's
'omp allocate' for stack variables.

libgomp/ChangeLog:

* libgomp.texi (OpenMP Impl. Status): Mention that Fortran now
supports the allocate directive for stack variables.
* testsuite/libgomp.fortran/allocate-5a.f90: Renamed from
testsuite/libgomp.fortran/allocate-5.f90.
* testsuite/libgomp.fortran/allocate-5.f90: New test.
* testsuite/libgomp.fortran/allocate-6.f90: New test.
* testsuite/libgomp.fortran/allocate-7.f90: New test.
* testsuite/libgomp.fortran/allocate-8.f90: New test.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/allocate-14.c: Fix directive name.
* c-c++-common/gomp/allocate-15.c: Likewise.
* c-c++-common/gomp/allocate-9.c: Fix comment typo.
* gfortran.dg/gomp/allocate-4.f90: Remove sorry dg-error.
* gfortran.dg/gomp/allocate-7.f90: Likewise.
* gfortran.dg/gomp/allocate-10.f90: New test.
* gfortran.dg/gomp/allocate-11.f90: New test.
* gfortran.dg/gomp/allocate-12.f90: New test.
* gfortran.dg/gomp/allocate-13.f90: New test.
* gfortran.dg/gomp/allocate-14.f90: New test.
* gfortran.dg/gomp/allocate-15.f90: New test.
* gfortran.dg/gomp/allocate-8.f90: New test.
* gfortran.dg/gomp/allocate-9.f90: New test.

(cherry picked from commit 969f5c3eaa7f073f532206ced0f177b4eb58aee2)

6 months agoFortran: Fix parse-dump-tree for OpenMP ALLOCATE clause
Tobias Burnus [Thu, 26 Oct 2023 09:23:31 +0000 (11:23 +0200)] 
Fortran: Fix parse-dump-tree for OpenMP ALLOCATE clause

Commit r14-1301-gd64e8e1224708e added u2.allocator to gfc_omp_namelist
for better readability and to permit to use namelist->expr for code
like the following:
  !$omp allocators allocate(align(32) : dt%alloc_comp)
    allocate (dt%alloc_comp(5))
  !$omp allocate(dt%alloc_comp2) align(64)
    allocate (dt%alloc_comp2(10))
However, for the parse-tree dump the change was incomplete.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_omp_namelist): Fix dump of the allocator
modifier of OMP_LIST_ALLOCATE.

(cherry picked from commit 99e3214f582b08b69b11b53eb3fc73b0919ef4f1)

6 months agoMerge branch 'releases/gcc-13' into devel/omp/gcc-13
Tobias Burnus [Thu, 26 Oct 2023 09:19:57 +0000 (11:19 +0200)] 
Merge branch 'releases/gcc-13' into devel/omp/gcc-13

Merge up to r13-7985-g319e887bdddfb8b9244f9310a54c1f08b7e8f0e8 (26th Oct 2023)

6 months agoOpenMP/Fortran: Merge upstream 'omp allocators' with OG13 'omp allocate'
Tobias Burnus [Thu, 26 Oct 2023 09:17:40 +0000 (11:17 +0200)] 
OpenMP/Fortran: Merge upstream 'omp allocators' with OG13 'omp allocate'

This merges mainline's
  r14-1301-gd64e8e1224708e
  Fortran/OpenMP: Add parsing support for allocators/allocate directives
into OG13.

In theory, that just replaces (reverts) the OG13-only commit
  6ce5ee77f73 Add parsing support for allocate directive (OpenMP 5.0)
  by Hafiz Abid Qadeer  <abidh@codesourcery.com>

However, the replacement is not full - thus, this commit does much more:
  While mainline support 'omp allocators' besides 'omp allocate' and
  the latter also for stack and pointer variables,
  the OG13 branch supports actual allocation with the directive version.
* Thus, this commit wires the mainline's executive allocate + new allocators
  with the OG13 GOMP_alloc/GOMP_free handling.
* It also handles now the 'align' clause/modifier.
* By defaulting to 'omp allocators', it re-uses the ALLOCATE clause in the
  ME instead of using the new ALLOCATOR clause, which has now been removed
  from the ME code.

On the FE side, it also includes a modified version of:
  https://gcc.gnu.org/pipermail/gcc-patches/2023-October/634096.html
  [Patch] OpenMP/Fortran: Handle unlisted items in 'omp allocators' + exec. 'omp allocate'

The whole patch cannot be easily disentangled and parts of
6ce5ee77f73 remain in a revised form. For those bits, the
credits belong to Abid.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_omp_namelist, show_omp_node,
show_code_node): Dump EXEC_OMP_ALLOCATORS update for struct changes.
* gfortran.h (enum gfc_statement): Add ST_OMP_(END_)ALLOCATORS.
(gfc_omp_namelist): Add allocator to union u2.
(enum): Remove OMP_LIST_ALLOCATOR.
(gfc_namespace): Add omp_allocate.
(enum gfc_exec_op): Add EXEC_OMP_ALLOCATORS.
(gfc_resolve_omp_allocate): New prototype.
* match.cc (gfc_free_omp_namelist): Free u2.allocator.
* match.h (gfc_match_omp_allocators): New prototype.
* openmp.cc (gfc_omp_directives): Enable allocate/allocator.
(gfc_match_omp_variable_list): Add reject_common_vars Boolean arg.
(enum omp_mask2): Remove OMP_CLAUSE_ALLOCATOR.
(gfc_match_omp_clauses): Update for struct change.
(OMP_ALLOCATE_CLAUSES): Remove.
(OMP_ALLOCATORS_CLAUSES): Add.
(gfc_match_omp_allocate): Replace by upstream version.
(gfc_match_omp_allocators, is_predefined_allocator,
gfc_resolve_omp_allocate): New.
(verify_omp_clauses_symbol_dups): Update for allocate/allocator.
(resolve_omp_clauses): Update from mainline.
(omp_code_to_statement): Add EXEC_OMP_ALLOCATORS.
prepare_omp_allocated_var_list_for_cleanup,
check_allocate_directive_restrictions, EMPTY_VAR_LIST,
gfc_resolve_omp_allocate): Remove.
(gfc_resolve_omp_directive): Add EXEC_OMP_ALLOCATORS.
* parse.cc (check_omp_allocate_stmt, decode_omp_directive
next_statement, case_omp_decl, gfc_ascii_statement,
verify_st_order, parse_openmp_allocate_block,
parse_omp_structured_block, parse_executable): Update from mainline.
* resolve.cc (gfc_resolve_blocks, resolve_codes): Handle allocate
and allocator.
* st.cc (gfc_free_statement): And EXEC_OMP_ALLOCATORS.
* trans-decl.cc (gfc_trans_deferred_vars): Use OMP_LIST_ALLOCATE
instead of OMP_LIST_ALLOCATOR.
* trans-openmp.cc (gfc_trans_omp_clauses): Remove OMP_LIST_ALLOCATOR,
update allocate handling.
(gfc_trans_omp_allocate): Renamed to ...
(gfc_trans_omp_allocators): ... this.
(gfc_split_omp_clauses, gfc_trans_omp_directive): Update.
* trans.cc (trans_code): Handle EXEC_OMP_ALLOCATORS.

gcc/ChangeLog:

* omp-low.cc (scan_sharing_clauses): Update message for directive use.
(lower_omp_allocate, lower_omp_1): Update for clause changes; handle
alignment.
* tree-core.h (enum omp_clause_code): Remove OMP_CLAUSE_ALLOCATOR.
* tree-pretty-print.cc (dump_omp_clause): Likewise.
* tree.cc (omp_clause_num_ops): Likewise.
* tree.h (OMP_ALLOCATE_DECL, OMP_ALLOCATE_ALLOCATOR): Remove.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/allocate-2a.f90: Add exec stmt.
* testsuite/libgomp.fortran/allocate-4.f90: Update dg-error
* testsuite/libgomp.fortran/allocate-5.f90: Likewise; add exec stmt.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/allocate-2.f90: Update dg-warning.
* gfortran.dg/gomp/allocate-4.f90: New upstream test.
* gfortran.dg/gomp/allocate-5.f90: New upstream test.
* gfortran.dg/gomp/allocate-6.f90: New upstream test.
* gfortran.dg/gomp/allocate-7.f90: New upstream test.
* gfortran.dg/gomp/allocate-4a.f90: Renamed from allocate-4.f90
* gfortran.dg/gomp/allocate-6a.f90: Renamed from allocate-6.f90
* gfortran.dg/gomp/allocate-7a.f90: Renamed from allocate-7.f90
* gfortran.dg/gomp/allocate-9a.f90: New test.
* gfortran.dg/gomp/allocators-1.f90: New upstream test.
* gfortran.dg/gomp/allocators-2.f90: New upstream test.

6 months agoLoongArch: Define macro CLEAR_INSN_CACHE.
Lulu Cheng [Mon, 23 Oct 2023 01:07:32 +0000 (09:07 +0800)] 
LoongArch: Define macro CLEAR_INSN_CACHE.

LoongArch's microstructure ensures cache consistency by hardware.
Due to out-of-order execution, "ibar" is required to ensure the visibility of the
store (invalidated icache) executed by this CPU before "ibar" (to the instance).
"ibar" will not invalidate the icache, so the start and end parameters are not Affect
"ibar" performance.

gcc/ChangeLog:

* config/loongarch/loongarch.h (CLEAR_INSN_CACHE): New definition.

(cherry picked from commit 5697ed0327f23d2e2ec4f7beec3b3d02f463173c)

6 months agoLoongArch: Implement __builtin_thread_pointer for TLS.
chenxiaolong [Tue, 24 Oct 2023 06:40:14 +0000 (14:40 +0800)] 
LoongArch: Implement __builtin_thread_pointer for TLS.

gcc/ChangeLog:

* config/loongarch/loongarch.md (get_thread_pointer<mode>):Adds the
instruction template corresponding to the __builtin_thread_pointer
function.
* doc/extend.texi:Add the __builtin_thread_pointer function support
description to the documentation.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/builtin_thread_pointer.c: New test.

(cherry picked from commit 1b30ef7cea773e0af527dbf821e0be42b6a264f8)

6 months agoDaily bump.
GCC Administrator [Thu, 26 Oct 2023 00:20:46 +0000 (00:20 +0000)] 
Daily bump.

6 months agolibstdc++: Build libstdc++_libbacktrace.a as PIC [PR111936]
Jonathan Wakely [Tue, 24 Oct 2023 15:56:30 +0000 (16:56 +0100)] 
libstdc++: Build libstdc++_libbacktrace.a as PIC [PR111936]

In order for std::stacktrace to be used in a shared library, the
libbacktrace symbols need to be built with -fPIC. Add the libtool
-prefer-pic flag to the commands in src/libbacktrace/Makefile so that
the archive contains PIC objects.

libstdc++-v3/ChangeLog:

PR libstdc++/111936
* src/libbacktrace/Makefile.am: Add -prefer-pic to libtool
compile commands.
* src/libbacktrace/Makefile.in: Regenerate.

(cherry picked from commit f32c1e1e96ffef6512ce025942b51f3967a3e7f2)

6 months agolibstdc++: Include cstdarg in freestanding
Paul M. Bendixen [Fri, 21 Jul 2023 21:35:25 +0000 (23:35 +0200)] 
libstdc++: Include cstdarg in freestanding

P1642 includes cstdarg in the full headers to include.
This commit includes it along with cstdalign and cstdbool that were
left out when updating in an earlier commit.

libstdc++/Changelog

* include/Makefile.am: Move cstdarg, cstdalign and cstdbool to
freestanding.
* include/Makefile.in: Regenerate.

Signed-off-by: Paul M. Bendixen <paulbendixen@gmail.com>
(cherry picked from commit c1eee808a93a94a18cffef59432e3422ed4e9b27)

6 months agoDaily bump.
GCC Administrator [Wed, 25 Oct 2023 00:24:37 +0000 (00:24 +0000)] 
Daily bump.

6 months agoRemove obsolete debugging formats from names list
Mark Harmstone [Tue, 24 Oct 2023 07:04:25 +0000 (09:04 +0200)] 
Remove obsolete debugging formats from names list

* opts.cc (debug_type_names): Remove stabs and xcoff.
(df_set_names): Adjust.

(cherry picked from commit 724badcadf889b5798321620aeed16b61e91fe72)

6 months agoDaily bump.
GCC Administrator [Tue, 24 Oct 2023 00:25:42 +0000 (00:25 +0000)] 
Daily bump.

6 months agolibstdc++: [_Hashtable] Do not reuse untrusted cached hash code
François Dumont [Wed, 18 Oct 2023 17:35:32 +0000 (19:35 +0200)] 
libstdc++: [_Hashtable] Do not reuse untrusted cached hash code

On merge, reuse a merged node's possibly cached hash code only if we are on the
same type of hash and this hash is stateless.

Usage of function pointers or std::function as hash functor will prevent reusing
cached hash code.

libstdc++-v3/ChangeLog

* include/bits/hashtable_policy.h
(_Hash_code_base::_M_hash_code(const _Hash&, const _Hash_node_value<>&)): Remove.
(_Hash_code_base::_M_hash_code<_H2>(const _H2&, const _Hash_node_value<>&)): Remove.
* include/bits/hashtable.h
(_M_src_hash_code<_H2>(const _H2&, const key_type&, const __node_value_type&)): New.
(_M_merge_unique<>, _M_merge_multi<>): Use latter.
* testsuite/23_containers/unordered_map/modifiers/merge.cc
(test04, test05, test06): New test cases.

6 months agoSH: Fix PR 111001
Oleg Endo [Mon, 23 Oct 2023 13:08:37 +0000 (22:08 +0900)] 
SH: Fix PR 111001

gcc/ChangeLog:

PR target/111001
* config/sh/sh_treg_combine.cc (sh_treg_combine::record_set_of_reg):
Skip over nop move insns.

6 months agors6000: Make 32 bit stack_protect support prefixed insn [PR111367]
Kewen Lin [Thu, 12 Oct 2023 05:05:03 +0000 (00:05 -0500)] 
rs6000: Make 32 bit stack_protect support prefixed insn [PR111367]

As PR111367 shows, with prefixed insn supported, some of
checkings consider it's able to leverage prefixed insn
for stack protect related load/store, but since we don't
actually change the emitted assembly for 32 bit, it can
cause the assembler error as exposed.

Mike's commit r10-4547-gce6a6c007e5a98 has already handled
the 64 bit case (DImode), this patch is to treat the 32
bit case (SImode) by making use of mode iterator P and
ptrload attribute iterator, also fixes the constraints
to match the emitted operand formats.

PR target/111367

gcc/ChangeLog:

* config/rs6000/rs6000.md (stack_protect_setsi): Support prefixed
instruction emission and incorporate to stack_protect_set<mode>.
(stack_protect_setdi): Rename to ...
(stack_protect_set<mode>): ... this, adjust constraint.
(stack_protect_testsi): Support prefixed instruction emission and
incorporate to stack_protect_test<mode>.
(stack_protect_testdi): Rename to ...
(stack_protect_test<mode>): ... this, adjust constraint.

gcc/testsuite/ChangeLog:

* g++.target/powerpc/pr111367.C: New test.

(cherry picked from commit 530babc2058be5f2b06b1541384e7b730c368b93)

6 months agoDaily bump.
GCC Administrator [Mon, 23 Oct 2023 00:21:10 +0000 (00:21 +0000)] 
Daily bump.

6 months agoDaily bump.
GCC Administrator [Sun, 22 Oct 2023 00:20:27 +0000 (00:20 +0000)] 
Daily bump.

6 months agoFortran: out of bounds access with nested implied-do IO [PR111837]
Harald Anlauf [Mon, 16 Oct 2023 19:02:20 +0000 (21:02 +0200)] 
Fortran: out of bounds access with nested implied-do IO [PR111837]

gcc/fortran/ChangeLog:

PR fortran/111837
* frontend-passes.cc (traverse_io_block): Dependency check of loop
nest shall be triangular, not banded.

gcc/testsuite/ChangeLog:

PR fortran/111837
* gfortran.dg/implied_do_io_8.f90: New test.

(cherry picked from commit 5ac63ec5da2e93226457bea4dbb3a4f78d5d82c2)

6 months agolibstdc++: Workaround for LLVM-61763 in <ranges>
Benjamin Brock [Fri, 20 Oct 2023 17:07:50 +0000 (18:07 +0100)] 
libstdc++: Workaround for LLVM-61763 in <ranges>

This patch adds a small workaround that avoids declaring constrained
friends when compiling with Clang, instead making some members public.
MSVC's standard library has implemented a similar workaround.

Signed-off-by: Benjamin Brock <brock@cs.berkeley.edu>
libstdc++-v3/ChangeLog:

* include/std/ranges (zip_view, adjacent_view): Implement
workaround for LLVM-61763.

(cherry picked from commit be34a8b538c0f04b11a428bd1a9340eb19dec13f)

6 months agolibstdc++: Fix formatting of filesystem directory iterators
Jonathan Wakely [Tue, 3 Oct 2023 16:35:38 +0000 (17:35 +0100)] 
libstdc++: Fix formatting of filesystem directory iterators

Fix indentation.

libstdc++-v3/ChangeLog:

* include/bits/fs_dir.h (operator==(default_sentinel_t)): Fix
indentation.

(cherry picked from commit 77209d43f1f38f153863a1845b64542cca79c2cb)

6 months agolibstdc++: Ensure active union member is correctly set
Nathaniel Shead [Fri, 29 Sep 2023 09:30:41 +0000 (10:30 +0100)] 
libstdc++: Ensure active union member is correctly set

This patch ensures that the union members for std::string and
std::variant are always properly set when a change occurs.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: (basic_string(basic_string&&)):
Activate _M_local_buf when needed.
(basic_string(basic_string&&, const _Alloc&)): Likewise.
* include/bits/basic_string.tcc: (basic_string::swap): Likewise.
* include/std/variant: (__detail::__variant::__construct_n): New.
(__detail::__variant::__emplace): Use __construct_n.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(cherry picked from commit 28adad7a32ed92a3c0906b38411c4ed686bbacc5)

6 months agoDaily bump.
GCC Administrator [Sat, 21 Oct 2023 00:21:04 +0000 (00:21 +0000)] 
Daily bump.

6 months agoc-family: char8_t and aliasing in C vs C++ [PR111884]
Marek Polacek [Thu, 19 Oct 2023 20:32:10 +0000 (16:32 -0400)] 
c-family: char8_t and aliasing in C vs C++ [PR111884]

In the PR, Joseph says that in C char8_t is not a distinct type.  So
we should behave as if it can alias anything, like ordinary char.
In C, unsigned_char_type_node == char8_type_node, so with this patch
we return 0 instead of -1.  And the following comment says:

  /* The C standard guarantees that any object may be accessed via an
     lvalue that has narrow character type (except char8_t).  */
  if (t == char_type_node
      || t == signed_char_type_node
      || t == unsigned_char_type_node)
    return 0;

Which appears to be wrong, so I'm adjusting that as well.

PR c/111884

gcc/c-family/ChangeLog:

* c-common.cc (c_common_get_alias_set): Return -1 for char8_t only
in C++.

gcc/testsuite/ChangeLog:

* c-c++-common/alias-1.c: New test.

(cherry picked from commit 281699fbff6262766674ab13087d37db751cd40a)

6 months agoSH: Fix PR 101177
Oleg Endo [Fri, 20 Oct 2023 09:48:34 +0000 (18:48 +0900)] 
SH: Fix PR 101177

Fix accidentally inverted comparison.

gcc/ChangeLog:

PR target/101177
* config/sh/sh.md (unnamed split pattern): Fix comparison of
find_regno_note result.

6 months agoDaily bump.
GCC Administrator [Fri, 20 Oct 2023 00:20:24 +0000 (00:20 +0000)] 
Daily bump.

6 months agoc++: Make -Wunknown-pragmas controllable by #pragma GCC diagnostic [PR89038]
Lewis Hyatt [Wed, 18 Oct 2023 16:37:08 +0000 (12:37 -0400)] 
c++: Make -Wunknown-pragmas controllable by #pragma GCC diagnostic [PR89038]

As noted on the PR, commit r13-1544, the fix for PR53431, did not handle
the specific case of -Wunknown-pragmas, because that warning is issued
during preprocessing, but not by libcpp directly (it comes from the
cb_def_pragma callback).  Address that by handling this pragma in
addition to libcpp pragmas during the early pragma handler.

gcc/c-family/ChangeLog:

PR c++/89038
* c-pragma.cc (handle_pragma_diagnostic_impl):  Handle
-Wunknown-pragmas during early processing.

gcc/testsuite/ChangeLog:

PR c++/89038
* c-c++-common/cpp/Wunknown-pragmas-1.c: New test.

6 months agoLibF7: Implement mul_mant for devices without MUL instruction.
Georg-Johann Lay [Wed, 18 Oct 2023 16:59:17 +0000 (18:59 +0200)] 
LibF7: Implement mul_mant for devices without MUL instruction.

libgcc/config/avr/libf7/
* libf7-asm.sx (mul_mant): Implement for devices without MUL.
* asm-defs.h (wmov) [!HAVE_MUL]: Fix regno computation.
* t-libf7 (F7_ASM_FLAGS): Add -g0.

6 months agoDaily bump.
GCC Administrator [Thu, 19 Oct 2023 00:21:56 +0000 (00:21 +0000)] 
Daily bump.

6 months agolra: Avoid unfolded plus-0
Richard Sandiford [Wed, 18 Oct 2023 17:44:57 +0000 (18:44 +0100)] 
lra: Avoid unfolded plus-0

While backporting another patch to an earlier release, I hit a
situation in which lra_eliminate_regs_1 would eliminate an address to:

    (plus (reg:P R) (const_int 0))

This address compared not-equal to plain:

    (reg:P R)

which caused an ICE in a later peephole2.  (The ICE showed up in
gfortran.fortran-torture/compile/pr80464.f90 on the branch but seems
to be latent on trunk.)

These unfolded PLUSes shouldn't occur in the insn stream, and later code
in the same function tried to avoid them.

gcc/
PR target/111528
* lra-eliminations.cc (lra_eliminate_regs_1): Use simplify_gen_binary
rather than gen_rtx_PLUS.

(cherry picked from commit 10d59b802a7db9ae908291fb20627c1493cfa26c)

6 months agoPR modula2/111756: Re-building all-gcc after source changes fails to link
Gaius Mulley [Wed, 18 Oct 2023 02:09:29 +0000 (03:09 +0100)] 
PR modula2/111756: Re-building all-gcc after source changes fails to link

When having modula-2 enabled in a development tree and there are any
changes that trigger rebuilds in m2/ doing a 'make all-gcc' in the
build directory might fail due to lack of dependency tracking.
This patch introduces build dependencies into gcc/m2/Make-lang.in using
-M* options.

gcc/m2/ChangeLog:

PR modula2/111756
* Make-lang.in (CM2DEP): New define conditionally set if
($(CXXDEPMODE),depmode=gcc3).
(m2/gm2-gcc/%.o): Ensure $(@D)/$(DEPDIR) is created.
Add $(CM2DEP) to the $(COMPILER) command and use $(POSTCOMPILE).
(m2/gm2-gcc/m2configure.o): Ditto.
(m2/gm2-lang.o): Ditto.
(m2/m2pp.o): Ditto.
(m2/gm2-gcc/rtegraph.o): Ditto.
(m2/mc-boot/$(SRC_PREFIX)%.o): Ditto.
(m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto.
(m2/mc-boot-ch/$(SRC_PREFIX)%.o): Ditto.
(m2/mc-boot/main.o): Ditto.
(mcflex.o): Ditto.
(m2/gm2-libs-boot/M2RTS.o): Ditto.
(m2/gm2-libs-boot/%.o): Ditto.
(m2/gm2-libs-boot/%.o): Ditto.
(m2/gm2-libs-boot/RTcodummy.o): Ditto.
(m2/gm2-libs-boot/RTintdummy.o): Ditto.
(m2/gm2-libs-boot/wrapc.o): Ditto.
(m2/gm2-libs-boot/UnixArgs.o): Ditto.
(m2/gm2-libs-boot/choosetemp.o): Ditto.
(m2/gm2-libs-boot/errno.o): Ditto.
(m2/gm2-libs-boot/dtoa.o): Ditto.
(m2/gm2-libs-boot/ldtoa.o): Ditto.
(m2/gm2-libs-boot/termios.o): Ditto.
(m2/gm2-libs-boot/SysExceptions.o): Ditto.
(m2/gm2-libs-boot/SysStorage.o): Ditto.
(m2/gm2-compiler-boot/M2GCCDeclare.o): Ditto.
(m2/gm2-compiler-boot/M2Error.o): Ditto.
(m2/gm2-compiler-boot/%.o): Ditto.
(m2/gm2-compiler-boot/%.o): Ditto.
(m2/gm2-compiler-boot/m2flex.o): Ditto.
(m2/gm2-compiler/m2flex.o): Ditto.
(m2/gm2-libs/choosetemp.o): Ditto.
(m2/boot-bin/mklink$(exeext)): Ditto.
(m2/pge-boot/%.o): Ditto.
(m2/pge-boot/%.o): Ditto.
* README: Remove out of date info.
* gm2-compiler/M2Quads.mod (BuildStringAdrParam): Correct
procedure end name.
* gm2-compiler/SymbolTable.mod (GetVarPointerCheck): Add
default FALSE return value.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
6 months agoDaily bump.
GCC Administrator [Wed, 18 Oct 2023 00:21:03 +0000 (00:21 +0000)] 
Daily bump.

6 months agoLibF7: Re-generate f7-renames.h to pick up white-space from f7renames.sh.
Georg-Johann Lay [Tue, 17 Oct 2023 15:18:18 +0000 (17:18 +0200)] 
LibF7: Re-generate f7-renames.h to pick up white-space from f7renames.sh.

libgcc/config/avr/libf7/
* f7-renames.h: Re-renerate.

6 months agoLibF7: Implement fma / fmal.
Georg-Johann Lay [Tue, 17 Oct 2023 09:36:52 +0000 (11:36 +0200)] 
LibF7: Implement fma / fmal.

libgcc/config/avr/libf7/
* libf7.h (F7_SIZEOF): New macro.
* libf7-asm.sx: Use F7_SIZEOF instead of magic number "10".
(F7MOD_D_fma_, __fma): New module and function.
(fma) [-mdouble=64]: Define as alias for __fma.
(fmal) [-mlong-double=64]: Define as alias for __fma.
* libf7-common.mk (F7_ASM_PARTS): Add D_fma.

6 months agoDisparage slightly for the alternative which move DFmode between SSE_REGS and GENERAL...
liuhongt [Wed, 5 Jul 2023 05:45:11 +0000 (13:45 +0800)] 
Disparage slightly for the alternative which move DFmode between SSE_REGS and GENERAL_REGS.

For testcase

void __cond_swap(double* __x, double* __y) {
  bool __r = (*__x < *__y);
  auto __tmp = __r ? *__x : *__y;
  *__y = __r ? *__y : *__x;
  *__x = __tmp;
}

GCC-14 with -O2 and -march=x86-64 options generates the following code:

__cond_swap(double*, double*):
        movsd   xmm1, QWORD PTR [rdi]
        movsd   xmm0, QWORD PTR [rsi]
        comisd  xmm0, xmm1
        jbe     .L2
        movq    rax, xmm1
        movapd  xmm1, xmm0
        movq    xmm0, rax
.L2:
        movsd   QWORD PTR [rsi], xmm1
        movsd   QWORD PTR [rdi], xmm0
        ret

rax is used to save and restore DFmode value. In RA both GENERAL_REGS
and SSE_REGS cost zero since we didn't disparage the
alternative in movdf_internal pattern, according to register
allocation order, GENERAL_REGS is allocated. The patch add ? for
alternative (r,v) and (v,r) just like we did for movsf/hf/bf_internal
pattern, after that we get optimal RA.

__cond_swap:
.LFB0:
.cfi_startproc
movsd (%rdi), %xmm1
movsd (%rsi), %xmm0
comisd %xmm1, %xmm0
jbe .L2
movapd %xmm1, %xmm2
movapd %xmm0, %xmm1
movapd %xmm2, %xmm0
.L2:
movsd %xmm1, (%rsi)
movsd %xmm0, (%rdi)
ret

gcc/ChangeLog:

PR target/110170
* config/i386/i386.md (movdf_internal): Disparage slightly for
2 alternatives (r,v) and (v,r) by adding constraint modifier
'?'.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr110170-3.c: New test.

(cherry picked from commit 37a231cc7594d12ba0822077018aad751a6fb94e)

6 months agoDaily bump.
GCC Administrator [Tue, 17 Oct 2023 00:20:33 +0000 (00:20 +0000)] 
Daily bump.

6 months agoMerge branch 'releases/gcc-13' into devel/omp/gcc-13
Tobias Burnus [Mon, 16 Oct 2023 16:19:50 +0000 (18:19 +0200)] 
Merge branch 'releases/gcc-13' into devel/omp/gcc-13

Merge up to r13-7954-gcc87aaeceea58389b681e3a6a63f95e54f2b59cd (16th Oct 2023)

6 months agoFortran's gfc_match_char: %S to match symbol with host_assoc
Tobias Burnus [Mon, 16 Oct 2023 16:12:42 +0000 (18:12 +0200)] 
Fortran's gfc_match_char: %S to match symbol with host_assoc

gfc_match ("... %s ...", ...) matches a gfc_symbol but with
host_assoc = 0. This commit adds '%S' as variant which matches
with host_assoc = 1

gcc/fortran/ChangeLog:

* match.cc (gfc_match_char): Match with '%S' a symbol
with host_assoc = 1.

(cherry picked from commit 0607e93490058ec31b6ab57078c54771f139b870)

6 months agors6000: Use default target option node for callee by default [PR111380]
Kewen Lin [Mon, 16 Oct 2023 02:05:47 +0000 (21:05 -0500)] 
rs6000: Use default target option node for callee by default [PR111380]

As PR111380 (and the discussion in related PRs) shows, for
now how function rs6000_can_inline_p treats the callee
without any target option node is wrong.  It considers it's
always safe to inline this kind of callee, but actually its
target flags are from the command line options
(target_option_default_node), it's possible that the flags
of callee don't satisfy the condition of inlining, but it
is still inlined, then result in unexpected consequence.

As the associated test case pr111380-1.c shows, the caller
main is attributed with power8, but the callee foo is
compiled with power9 from command line, it's unexpected to
make main inline foo since foo can contain something that
requires power9 capability.  Without this patch, for lto
(with -flto) we can get error message (as it forces the
callee to have a target option node), but for non-lto, it's
inlined unexpectedly.

This patch is to make callee adopt target_option_default_node
when it doesn't have a target option node, it can avoid wrong
inlining decision and fix the inconsistency between LTO and
non-LTO.  It also aligns with what the other ports do.

PR target/111380

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_can_inline_p): Adopt
target_option_default_node when the callee has no option
attributes, also simplify the existing code accordingly.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr111380-1.c: New test.
* gcc.target/powerpc/pr111380-2.c: New test.

(cherry picked from commit 266dfed68b881702e9660889f63408054b7fa9c0)

6 months agors6000: Skip empty inline asm in rs6000_update_ipa_fn_target_info [PR111366]
Kewen Lin [Mon, 16 Oct 2023 02:05:40 +0000 (21:05 -0500)] 
rs6000: Skip empty inline asm in rs6000_update_ipa_fn_target_info [PR111366]

PR111366 exposes one thing that can be improved in function
rs6000_update_ipa_fn_target_info is to skip the given empty
inline asm string, since it's impossible to adopt any
hardware features (so far HTM).

Since this rs6000_update_ipa_fn_target_info related approach
exists in GCC12 and later, the affected project highway has
updated its target pragma with ",htm", see the link:
https://github.com/google/highway/commit/15e63d61eb535f478bc
I'd not bother to consider an inline asm parser for now but
will file a separated PR for further enhancement.

PR target/111366

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_update_ipa_fn_target_info): Skip
empty inline asm.

gcc/testsuite/ChangeLog:

* g++.target/powerpc/pr111366.C: New test.

(cherry picked from commit a65b38e361320e0aa45adbc969c704385ab1f45b)

6 months agoDaily bump.
GCC Administrator [Mon, 16 Oct 2023 00:20:54 +0000 (00:20 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Sun, 15 Oct 2023 00:20:24 +0000 (00:20 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Sat, 14 Oct 2023 00:19:21 +0000 (00:19 +0000)] 
Daily bump.

7 months agoDo not add partial equivalences with no uses.
Andrew MacLeod [Thu, 12 Oct 2023 21:06:36 +0000 (17:06 -0400)] 
Do not add partial equivalences with no uses.

PR tree-optimization/111622
* value-relation.cc (equiv_oracle::add_partial_equiv): Do not
register a partial equivalence if an operand has no uses.

7 months agoDaily bump.
GCC Administrator [Fri, 13 Oct 2023 00:21:00 +0000 (00:21 +0000)] 
Daily bump.

7 months agoLibF7: Implement atan2.
Georg-Johann Lay [Thu, 12 Oct 2023 13:32:41 +0000 (15:32 +0200)] 
LibF7: Implement atan2.

libgcc/config/avr/libf7/
* libf7.c (F7MOD_atan2_, f7_atan2): New module and function.
* libf7.h: Adjust comments.
* libf7-common.mk (CALL_PROLOGUES): Add atan2.

7 months agoDaily bump.
GCC Administrator [Thu, 12 Oct 2023 00:20:56 +0000 (00:20 +0000)] 
Daily bump.

7 months agoEnsure float equivalences include + and - zero.
Andrew MacLeod [Mon, 9 Oct 2023 17:40:15 +0000 (13:40 -0400)] 
Ensure float equivalences include + and - zero.

A floating point equivalence may not properly reflect both signs of
zero, so be pessimsitic and ensure both signs are included.

PR tree-optimization/111694
gcc/
* gimple-range-cache.cc (ranger_cache::fill_block_cache): Adjust
equivalence range.
* value-relation.cc (adjust_equivalence_range): New.
* value-relation.h (adjust_equivalence_range): New prototype.

gcc/testsuite/
* gcc.dg/pr111694.c: New.

7 months agotree-ssa-strlen: optimization skips clobbering store [PR111519]
Jakub Jelinek [Wed, 11 Oct 2023 06:58:29 +0000 (08:58 +0200)] 
tree-ssa-strlen: optimization skips clobbering store [PR111519]

The following testcase is miscompiled, because count_nonzero_bytes incorrectly
uses get_strinfo information on a pointer from which an earlier instruction
loads SSA_NAME stored at the current instruction.  get_strinfo shows a state
right before the current store though, so if there are some stores in between
the current store and the load, the string length information might have
changed.

The patch passes around gimple_vuse from the store and punts instead of using
strinfo on loads from MEM_REF which have different gimple_vuse from that.

2023-10-11  Richard Biener  <rguenther@suse.de>
    Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/111519
* tree-ssa-strlen.cc (strlen_pass::count_nonzero_bytes): Add vuse
argument and pass it through to recursive calls and
count_nonzero_bytes_addr calls.  Don't shadow the stmt argument, but
change stmt for gimple_assign_single_p statements for which we don't
immediately punt.
(strlen_pass::count_nonzero_bytes_addr): Add vuse argument and pass
it through to recursive calls and count_nonzero_bytes calls.  Don't
use get_strinfo if gimple_vuse (stmt) is different from vuse.  Don't
shadow the stmt argument.

* gcc.dg/torture/pr111519.c: New testcase.

(cherry picked from commit e75bf1985fdc9a5d3a307882a9251d8fd6e93def)

7 months agoDaily bump.
GCC Administrator [Wed, 11 Oct 2023 00:20:42 +0000 (00:20 +0000)] 
Daily bump.

7 months agoada: Fix infinite loop with multiple limited with clauses
Eric Botcazou [Tue, 26 Sep 2023 20:54:12 +0000 (22:54 +0200)] 
ada: Fix infinite loop with multiple limited with clauses

This occurs when one of the types has an incomplete declaration in addition
to its full declaration in its package. In this case AI05-129 says that the
incomplete type is not part of the limited view of the package, i.e. only
the full view is. Now, in the GNAT implementation, it's the opposite in the
regular view of the package, i.e. the incomplete type is the visible one.

That's why the implementation needs to also swap the types on the visibility
chain while it is swapping the views when the clauses are either installed
or removed. This works correctly for the installation, but does not for the
removal, so this change rewrites the code doing the latter.

gcc/ada/
PR ada/111434
* sem_ch10.adb (Replace): New procedure to replace an entity with
another on the homonym chain.
(Install_Limited_With_Clause): Rename Non_Lim_View to Typ for the
sake of consistency.  Call Replace to do the replacements and split
the code into the regular and the special cases.  Add debuggging
output controlled by -gnatdi.
(Install_With_Clause): Print the Parent_With and Implicit_With flags
in the debugging output controlled by -gnatdi.
(Remove_Limited_With_Unit.Restore_Chain_For_Shadow (Shadow)): Rewrite
using a direct replacement of E4 by E2.   Call Replace to do the
replacements.  Add debuggging output controlled by -gnatdi.

7 months agoDaily bump.
GCC Administrator [Tue, 10 Oct 2023 00:23:29 +0000 (00:23 +0000)] 
Daily bump.

7 months agoFortran/OpenMP: Fix handling of strictly structured blocks
Tobias Burnus [Sun, 8 Oct 2023 09:54:07 +0000 (11:54 +0200)] 
Fortran/OpenMP: Fix handling of strictly structured blocks

For strictly structured blocks, a BLOCK was created but the code
was placed after the block the outer structured block. Additionally,
labelled blocks were mishandled. As the code is now properly in a
BLOCK, it solves additional issues.

gcc/fortran/ChangeLog:

* parse.cc (parse_omp_structured_block): Make the user code end
up inside of BLOCK construct for strictly structured blocks;
fix fallout for 'section' and 'teams'.
* openmp.cc (resolve_omp_target): Fix changed BLOCK handling
for teams in target checking.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/strictly-structured-block-1.f90: New test.

gcc/testsuite/ChangeLog:

* gfortran.dg/block_17.f90: New test.
* gfortran.dg/gomp/strictly-structured-block-5.f90: New test.

(cherry picked from commit 6a8edd50a149f10621b59798c887c24c81c8b9ea)

7 months agoDaily bump.
GCC Administrator [Mon, 9 Oct 2023 00:20:38 +0000 (00:20 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Sun, 8 Oct 2023 00:20:53 +0000 (00:20 +0000)] 
Daily bump.

7 months agoMATCH: Fix infinite loop between `vec_cond(vec_cond(a,b,0), c, d)` and `a & b`
Andrew Pinski [Thu, 5 Oct 2023 19:21:19 +0000 (12:21 -0700)] 
MATCH: Fix infinite loop between `vec_cond(vec_cond(a,b,0), c, d)` and `a & b`

Match has a pattern which converts `vec_cond(vec_cond(a,b,0), c, d)`
into `vec_cond(a & b, c, d)` but since in this case a is a comparison
fold will change `a & b` back into `vec_cond(a,b,0)` which causes an
infinite loop.
The best way to fix this is to enable the patterns for vec_cond(*,vec_cond,*)
only for GIMPLE so we don't get an infinite loop for fold any more.

Note this is a latent bug since these patterns were added in r11-2577-g229752afe3156a
and was exposed by r14-3350-g47b833a9abe1 where now able to remove a VIEW_CONVERT_EXPR.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR middle-end/111699

gcc/ChangeLog:

* match.pd ((c ? a : b) op d, (c ? a : b) op (c ? d : e),
(v ? w : 0) ? a : b, c1 ? c2 ? a : b : b): Enable only for GIMPLE.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr111699-1.c: New test.

(cherry picked from commit e77428a9a336f57e3efe3eff95f2b491d7e9be14)

7 months agoDaily bump.
GCC Administrator [Sat, 7 Oct 2023 00:20:44 +0000 (00:20 +0000)] 
Daily bump.

7 months agoMerge branch 'releases/gcc-13' into devel/omp/gcc-13
Tobias Burnus [Fri, 6 Oct 2023 08:00:00 +0000 (10:00 +0200)] 
Merge branch 'releases/gcc-13' into devel/omp/gcc-13

Merge up to r13-7936-g7c47e03df2a77f2e25e23887734a5e818aeca3f5 (6th Oct 2023)

7 months agoDaily bump.
GCC Administrator [Fri, 6 Oct 2023 00:20:32 +0000 (00:20 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Thu, 5 Oct 2023 00:21:56 +0000 (00:21 +0000)] 
Daily bump.

7 months agoFortran: Alloc comp of non-finalizable type not finalized [PR111674]
Paul Thomas [Wed, 4 Oct 2023 07:26:35 +0000 (08:26 +0100)] 
Fortran: Alloc comp of non-finalizable type not finalized [PR111674]

2023-10-04  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/37336
PR fortran/111674
* trans-expr.cc (gfc_trans_scalar_assign): Finalize components
on deallocation if derived type is not finalizable.

gcc/testsuite/
PR fortran/37336
PR fortran/111674
* gfortran.dg/allocate_with_source_25.f90: Final count in tree
dump reverts from 4 to original 6.
* gfortran.dg/finalize_38.f90: Add test for fix of PR111674.

(cherry picked from commit 84284e1c490e9235fca5cb85269ecfcb87eef4f1)

7 months agoDaily bump.
GCC Administrator [Wed, 4 Oct 2023 00:21:27 +0000 (00:21 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Tue, 3 Oct 2023 00:20:16 +0000 (00:20 +0000)] 
Daily bump.

7 months agolibstdc++: Force _Hash_node_value_base methods inline to fix abi (PR111050)
Tim Song [Wed, 6 Sep 2023 17:31:55 +0000 (19:31 +0200)] 
libstdc++: Force _Hash_node_value_base methods inline to fix abi (PR111050)

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=1b6f0476837205932613ddb2b3429a55c26c409d
changed _Hash_node_value_base to no longer derive from _Hash_node_base, which means
that its member functions expect _M_storage to be at a different offset. So explosions
result if an out-of-line definition is emitted for any of the member functions (say,
in a non-optimized build) and the resulting object file is then linked with code built
using older version of GCC/libstdc++.

libstdc++-v3/ChangeLog:

PR libstdc++/111050
* include/bits/hashtable_policy.h
(_Hash_node_value_base<>::_M_valptr(), _Hash_node_value_base<>::_M_v())
Add [[__gnu__::__always_inline__]].

(cherry picked from commit 2c1e3544a94c5d7354fad031e1f9731c3ce3af25)

7 months agoDisable generation of scalar modulo instructions.
Pat Haugen [Tue, 19 Sep 2023 18:19:59 +0000 (13:19 -0500)] 
Disable generation of scalar modulo instructions.

It was recently discovered that the scalar modulo instructions can suffer
noticeable performance issues for certain input values. This patch disables
their generation since the equivalent div/mul/sub sequence does not suffer
the same problem.

gcc/
* config/rs6000/rs6000.cc (rs6000_rtx_costs): Check whether the
modulo instruction is disabled.
* config/rs6000/rs6000.h (RS6000_DISABLE_SCALAR_MODULO): New.
* config/rs6000/rs6000.md (mod<mode>3, *mod<mode>3): Check it.
(define_expand umod<mode>3): New.
(define_insn umod<mode>3): Rename to *umod<mode>3 and check if the modulo
instruction is disabled.
(umodti3, modti3): Check if the modulo instruction is disabled.

gcc/testsuite/
* gcc.target/powerpc/clone1.c: Add xfails.
* gcc.target/powerpc/clone3.c: Likewise.
* gcc.target/powerpc/mod-1.c: Update scan strings and add xfails.
* gcc.target/powerpc/mod-2.c: Likewise.
* gcc.target/powerpc/p10-vdivq-vmodq.c: Add xfails.

(cherry picked from commit 58ab38213b979811d314f68e3f455c28a1d44140)

7 months agoDaily bump.
GCC Administrator [Mon, 2 Oct 2023 00:20:40 +0000 (00:20 +0000)] 
Daily bump.

7 months agoFix PR 111331: wrong code for `a > 28 ? MIN<a, 28> : 29`
Andrew Pinski [Fri, 8 Sep 2023 05:13:31 +0000 (22:13 -0700)] 
Fix PR 111331: wrong code for `a > 28 ? MIN<a, 28> : 29`

The problem here is after r6-7425-ga9fee7cdc3c62d0e51730,
the comparison to see if the transformation could be done was using the
wrong value. Instead of see if the inner was LE (for MIN and GE for MAX)
the outer value, it was comparing the inner to the value used in the comparison
which was wrong.

Committed to GCC 13 branch after bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR tree-optimization/111331
* tree-ssa-phiopt.cc (minmax_replacement):
Fix the LE/GE comparison for the
`(a CMP CST1) ? max<a,CST2> : a` optimization.

gcc/testsuite/ChangeLog:

PR tree-optimization/111331
* gcc.c-torture/execute/pr111331-1.c: New test.
* gcc.c-torture/execute/pr111331-2.c: New test.
* gcc.c-torture/execute/pr111331-3.c: New test.

(cherry picked from commit 30e6ee074588bacefd2dfe745b188bb20c81fe5e)

7 months agoFix PR 110386: backprop vs ABSU_EXPR
Andrew Pinski [Sun, 24 Sep 2023 04:53:09 +0000 (21:53 -0700)] 
Fix PR 110386: backprop vs ABSU_EXPR

The issue here is that when backprop tries to go
and strip sign ops, it skips over ABSU_EXPR but
ABSU_EXPR not only does an ABS, it also changes the
type to unsigned.
Since strip_sign_op_1 is only supposed to strip off
sign changing operands and not ones that change types,
removing ABSU_EXPR here is correct. We don't handle
nop conversions so this does cause any missed optimizations either.

Committed to the GCC 13 branch after bootstrapped and
tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/110386

gcc/ChangeLog:

* gimple-ssa-backprop.cc (strip_sign_op_1): Remove ABSU_EXPR.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr110386-1.c: New test.
* gcc.c-torture/compile/pr110386-2.c: New test.

(cherry picked from commit 2bbac12ea7bd8a3eef5382e1b13f6019df4ec03f)

7 months agoDaily bump.
GCC Administrator [Sun, 1 Oct 2023 00:21:58 +0000 (00:21 +0000)] 
Daily bump.

7 months agoFixup d9b3269bdc.
Andre Vehreschild [Sat, 30 Sep 2023 13:10:38 +0000 (15:10 +0200)] 
Fixup d9b3269bdc.

Adapt to different parameter count in comparison to gcc-14.

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_trans_deferred_array): Use correct
position for statements to add to guarded block.

7 months agoDaily bump.
GCC Administrator [Sat, 30 Sep 2023 00:20:59 +0000 (00:20 +0000)] 
Daily bump.

7 months agoFortran: Free alloc. comp. in allocated coarrays only.
Andre Vehreschild [Thu, 28 Sep 2023 07:30:12 +0000 (09:30 +0200)] 
Fortran: Free alloc. comp. in allocated coarrays only.

When freeing allocatable components of an allocatable coarray, add
a check that the coarray is still allocated, before accessing the
components.

This patch adds to PR fortran/37336, but does not fix it completely.

gcc/fortran/ChangeLog:
PR fortran/37336
* trans-array.cc (structure_alloc_comps): Deref coarray.
(gfc_trans_deferred_array): Add freeing of components after
check for allocated coarray.

gcc/testsuite/ChangeLog:
PR fortran/37336
* gfortran.dg/coarray/alloc_comp_6.f90: New test.
* gfortran.dg/coarray/alloc_comp_7.f90: New test.

(cherry picked from commit 9a63a62dfd73e159f1956e9b04b555c445de4e78)

7 months agoMerge branch 'releases/gcc-13' into devel/omp/gcc-13
Tobias Burnus [Fri, 29 Sep 2023 12:27:17 +0000 (14:27 +0200)] 
Merge branch 'releases/gcc-13' into devel/omp/gcc-13

Merge up to r13-7922-gb5b98a2d055d967d1fc92859827839c83c9368d7 (29th Sep 2023)

7 months agoAArch64: List official cores before codenames
Wilco Dijkstra [Wed, 13 Sep 2023 12:16:14 +0000 (13:16 +0100)] 
AArch64: List official cores before codenames

List official cores first so that -mcpu=native does not show a codename with
-v or in errors/warnings.

gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (neoverse-n1): Place before ares.
(neoverse-v1): Place before zeus.
(neoverse-v2): Place before demeter.
* config/aarch64/aarch64-tune.md: Regenerate.

(cherry picked from commit 64d5bc35c8c2a66ac133a3e6ace820b0ad8a63fb)

7 months agoAArch64: Fix memmove operand corruption [PR111121]
Wilco Dijkstra [Tue, 26 Sep 2023 15:42:45 +0000 (16:42 +0100)] 
AArch64: Fix memmove operand corruption [PR111121]

A MOPS memmove may corrupt registers since there is no copy of the input
operands to temporary registers.  Fix this by calling
aarch64_expand_cpymem_mops.

Reviewed-by: Richard Sandiford <richard.sandiford@arm.com>
gcc/ChangeLog/
PR target/111121
* config/aarch64/aarch64.md (aarch64_movmemdi): Add new expander.
(movmemdi): Call aarch64_expand_cpymem_mops for correct expansion.
* config/aarch64/aarch64.cc (aarch64_expand_cpymem_mops): Add support
for memmove.
* config/aarch64/aarch64-protos.h (aarch64_expand_cpymem_mops): Add new
function.

gcc/testsuite/ChangeLog/
PR target/111121
* gcc.target/aarch64/mops_4.c: Add memmove testcases.

(cherry picked from commit d8b56c95782aeeee79ec40932ca88d00fd9f2ee2)

7 months agoDaily bump.
GCC Administrator [Fri, 29 Sep 2023 00:21:32 +0000 (00:21 +0000)] 
Daily bump.

7 months agoDaily bump.
GCC Administrator [Thu, 28 Sep 2023 09:54:02 +0000 (09:54 +0000)] 
Daily bump.

7 months agolibstdc++: Add test for illegal pointer arithmetic in format [PR111102]
Paul Dreik [Thu, 24 Aug 2023 10:43:43 +0000 (11:43 +0100)] 
libstdc++: Add test for illegal pointer arithmetic in format [PR111102]

libstdc++-v3/ChangeLog:

PR libstdc++/111102
* testsuite/std/format/string.cc: Check wide character format
strings with out-of-range widths.

(cherry picked from commit 7564fe98657ad5ede34bd08f5279778fa8698865)

7 months agolibstdc++: [_GLIBCXX_INLINE_VERSION] Fix <format> friend declaration
François Dumont [Wed, 23 Aug 2023 17:15:43 +0000 (19:15 +0200)] 
libstdc++: [_GLIBCXX_INLINE_VERSION] Fix <format> friend declaration

GCC do not consider the inline namespace in friend function declarations.
This is PR c++/59526, we need to explicit this namespace.

libstdc++-v3/ChangeLog:

* include/std/format (std::__format::_Arg_store): Explicit version
namespace on make_format_args friend declaration.

(cherry picked from commit 92456291849fe88303bbcab366f41dcd4a885ad5)

7 months agolibstdc++: fix illegal pointer arithmetic in format [PR111102]
Paul Dreik [Thu, 24 Aug 2023 10:43:43 +0000 (11:43 +0100)] 
libstdc++: fix illegal pointer arithmetic in format [PR111102]

When parsing a format string, the width is parsed into an unsigned short
but the result is not checked in the case the format string is not a
char string (such as a wide string). In case the parse fails, a null
pointer is returned which is used for pointer arithmetic which is
undefined behaviour.

Signed-off-by: Paul Dreik <gccpatches@pauldreik.se>
libstdc++-v3/ChangeLog:

PR libstdc++/111102
* include/std/format (__format::__parse_integer): Check for
non-null pointer.

(cherry picked from commit dd4bdb9eea436bf06f175d8dbfc2190377455be4)

7 months agolibstdc++: Minor fixes for some warnings in <format>
Jonathan Wakely [Tue, 8 Aug 2023 15:29:17 +0000 (16:29 +0100)] 
libstdc++: Minor fixes for some warnings in <format>

libstdc++-v3/ChangeLog:

* include/std/format: Fix some warnings.
(__format::__write(Ctx&, basic_string_view<CharT>)): Remove
unused function template.

(cherry picked from commit b9e5a4b4f035ba85b1a4065b751c2d583206b4e3)

7 months agolibstdc++: Fix std::format alternate form for floating-point [PR108046]
Jonathan Wakely [Thu, 27 Jul 2023 13:07:09 +0000 (14:07 +0100)] 
libstdc++: Fix std::format alternate form for floating-point [PR108046]

A decimal point was being added to the end of the string for {:#.0}
because the __expc character was not being set, for the _Pres_none
presentation type, so __s.find(__expc) didn't the 'e' in "1e+01" and so
we created "1e+01." by appending the radix char to the end.

This can be fixed by ensuring that __expc='e' is set for the _Pres_none
case. I realized we can also set __expc='P' and __expc='E' when needed,
to save a call to std::toupper later.

For the {:#.0g} format, __expc='e' was being set and so the 'e' was
found in "1e+10" but then __z = __prec - __sigfigs would wraparound to
SIZE_MAX. That meant we would decide not to add a radix char because the
number of extra characters to insert would be 1+SIZE_MAX i.e. zero.

This can be fixed by using __z == 0 when __prec == 0.

libstdc++-v3/ChangeLog:

PR libstdc++/108046
* include/std/format (__formatter_fp::format): Ensure __expc is
always set for all presentation types. Set __z correctly for
zero precision.
* testsuite/std/format/functions/format.cc: Check problem cases.

(cherry picked from commit 50bc490c090cc95175e6068ed7438788d7fd7040)

7 months agolibstdc++: Fix constexpr functions to conform to older standards
Jonathan Wakely [Wed, 9 Aug 2023 10:11:31 +0000 (11:11 +0100)] 
libstdc++: Fix constexpr functions to conform to older standards

Some constexpr functions were inadvertently relying on relaxed constexpr
rules from later standards.

libstdc++-v3/ChangeLog:

* include/bits/chrono.h (duration_cast): Do not use braces
around statements for C++11 constexpr rules.
* include/bits/stl_algobase.h (__lg): Rewrite as a single
statement for C++11 constexpr rules.
* include/experimental/bits/fs_path.h (path::string): Use
_GLIBCXX17_CONSTEXPR not _GLIBCXX_CONSTEXPR for 'if constexpr'.
* include/std/charconv (__to_chars_8): Initialize variable for
C++17 constexpr rules.

(cherry picked from commit b3a2b307b9deea719fb725a86df43b82176fe459)

7 months agoada: Fix missing call to Finalize_Protection for simple protected objects
Eric Botcazou [Mon, 18 Sep 2023 07:14:46 +0000 (09:14 +0200)] 
ada: Fix missing call to Finalize_Protection for simple protected objects

There is a glitch in Exp_Ch7.Build_Finalizer causing the finalizer to do
nothing for simple protected objects.

The change also removes redundant calls to the Is_Simple_Protected_Type
predicate and fixes a minor inconsistency between Requires_Cleanup_Actions
and Build_Finalizer for this case.

gcc/ada/

* exp_ch7.adb (Build_Finalizer.Process_Declarations): Remove call
to Is_Simple_Protected_Type as redundant.
(Build_Finalizer.Process_Object_Declaration): Do not retrieve the
corresponding record type for simple protected objects. Make the
flow of control more explicit in their specific processing.
* exp_util.adb (Requires_Cleanup_Actions): Return false for simple
protected objects present in library-level package bodies for the
sake of consistency with Build_Finalizer and remove call to
Is_Simple_Protected_Type as redundant.