]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
11 days agoDaily bump.
GCC Administrator [Mon, 27 Oct 2025 00:28:10 +0000 (00:28 +0000)] 
Daily bump.

12 days agox86-64: Use `movsxd` to perform SI-to-DI extension in Intel syntax
LIU Hao [Sat, 25 Oct 2025 09:19:34 +0000 (17:19 +0800)] 
x86-64: Use `movsxd` to perform SI-to-DI extension in Intel syntax

Although there's no possibility of ambiguity, Intel manual says the mnemonic
for DWORD-to-QWORD sign-extension operation should be MOVSXD. Some assemblers
(GNU AS, NASM) also overload MOVSX, but some others don't accept MOVSX (LLVM,
MASM, YASM in NASM mode) and require MOVSXD.

This mnemonic was introduced in r0-34259-g123bf9e3f4056d in 2001, and has not
been updated ever since.

gcc/ChangeLog:

PR target/119079
* config/i386/i386.md: Use `movsxd` to perform SI-to-DI extension in Intel
syntax.

Signed-off-by: LIU Hao <lh_mouse@126.com>
(cherry picked from commit 66b38349273525dfb86f0f74d6c928abdbf7154f)

12 days ago[aarch64] [testsuite] tolerate alternate insn selection [PR121599]
Alexandre Oliva [Sun, 26 Oct 2025 01:45:22 +0000 (22:45 -0300)] 
[aarch64] [testsuite] tolerate alternate insn selection [PR121599]

On gcc-14, instead of 'movi\td[0-9]*,#0', we select
'mov\tz[0-9]*\.b,#0', and the testcase fails.
As in pfalse* tests, tolerate the difference.

for  gcc/testsuite/ChangeLog

PR target/121599
* gcc.target/aarch64/sve2/pr121599.c: Tolerate alterate insn
selection.

(cherry picked from commit ba653cb0d26e004c10d20ebd9f009a0a823659b0)

12 days agoDaily bump.
GCC Administrator [Sun, 26 Oct 2025 00:28:10 +0000 (00:28 +0000)] 
Daily bump.

13 days agoFortran: fix "unstable" interfaces of external procedures [PR122206]
Harald Anlauf [Thu, 9 Oct 2025 16:43:22 +0000 (18:43 +0200)] 
Fortran: fix "unstable" interfaces of external procedures [PR122206]

In the testcase repeated invocations of a function showed an apparently
unstable interface.  This was caused by trying to guess an (inappropriate)
interface of the external procedure after processing of the procedure
arguments in gfc_conv_procedure_call.  The mis-guessed interface showed up
in subsequent uses of the procedure symbol in gfc_conv_procedure_call.  The
solution is to check for an existing interface of an external procedure
before trying to wildly guess based on just the actual arguments.

PR fortran/122206

gcc/fortran/ChangeLog:

* trans-types.cc (gfc_get_function_type): Do not clobber an
existing procedure interface.

gcc/testsuite/ChangeLog:

* gfortran.dg/interface_abstract_6.f90: New test.

(cherry picked from commit c474a50b42ac3f7561f628916cf58810044986b3)

13 days agoFortran: fix issue with I/O of array pointer [PR107968]
Harald Anlauf [Fri, 3 Oct 2025 19:16:19 +0000 (21:16 +0200)] 
Fortran: fix issue with I/O of array pointer [PR107968]

PR fortran/107968

gcc/fortran/ChangeLog:

* trans-io.cc (gfc_trans_transfer): Also scalarize I/O of section
of an array pointer.

gcc/testsuite/ChangeLog:

* gfortran.dg/implied_do_io_9.f90: New test.

(cherry picked from commit e3431c6fd4691d5a0c48ee78869e5f9a79f217c3)

13 days agoDaily bump.
GCC Administrator [Sat, 25 Oct 2025 00:28:20 +0000 (00:28 +0000)] 
Daily bump.

2 weeks agoAda: Fix segfault on file without final EOL with -gnatyc
Eric Botcazou [Fri, 24 Oct 2025 15:39:57 +0000 (17:39 +0200)] 
Ada: Fix segfault on file without final EOL with -gnatyc

The compiler overruns the source file buffer.

gcc/ada/
PR ada/118782
* styleg.adb (Is_Box_Comment): Also stop the loop at EOF.

2 weeks agoAda: Fix other instances of incorrect String lower bound in gnatlink
Nicolas Boulenguez [Fri, 24 Oct 2025 10:46:55 +0000 (12:46 +0200)] 
Ada: Fix other instances of incorrect String lower bound in gnatlink

This also reverts an unintentional change introduced by the initial fix.

gcc/ada/
PR ada/81087
* gnatlink.adb (Is_Prefix): Move around, streamline and return false
when the prefix is not strict.
(Gnatlink): Fix other instances of incorrect lower bound assumption.

2 weeks agox86: builtin-fabs-2.c: Also scan (%edi) for x32
H.J. Lu [Fri, 24 Oct 2025 08:23:19 +0000 (16:23 +0800)] 
x86: builtin-fabs-2.c: Also scan (%edi) for x32

Adjust gcc.target/i386/builtin-fabs-2.c to scan both (%rdi) and (%edi).

PR target/122323
* gcc.target/i386/builtin-fabs-2.c: Also scan (%edi)for x32.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 77c8be11d85d9f204d2eb1ba3c5d0cbf3cbce277)

2 weeks agotree-object-size.cc: Fix assert constant offset in check_for_plus_in_loops [PR122012]
Linsen Zhou [Fri, 17 Oct 2025 03:05:04 +0000 (11:05 +0800)] 
tree-object-size.cc: Fix assert constant offset in check_for_plus_in_loops [PR122012]

After commit 51b85dfeb19652bf3e0aaec08828ba7cee1e641c, when the
pointer offset is a variable in the loop, the object size of the
pointer may also need to be reexamined.
Which make gcc_assert in the check_for_plus_in_loops failed.

gcc/ChangeLog:

PR tree-optimization/122012
* tree-object-size.cc (check_for_plus_in_loops): Skip check
for the variable offset

gcc/testsuite/ChangeLog:

PR tree-optimization/122012
* gcc.dg/torture/pr122012.c: New test.

Signed-off-by: Linsen Zhou <i@lin.moe>
(cherry picked from commit 82cefc4898d4ccabe76e28d6626b91ca9e998923)

2 weeks agox86: Optimize copysign (x, const_double)
H.J. Lu [Sun, 19 Oct 2025 01:13:52 +0000 (09:13 +0800)] 
x86: Optimize copysign (x, const_double)

After

commit 3f176e1adc6bc9cc2c21222d776b51d9f43cb66b
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Thu Nov 9 13:59:39 2023 +0000

    middle-end: optimize fneg (fabs (x)) to copysign (x, -1) [PR109154]

fneg (fabs (x)) is expanded to copysign (x, -1).  Swap constraints for
operands[1] and operands[2] in copysign<mode>3 pattern to optimize

  y = copysign (x, const_double)

instead of

  y = copysign (const_double, x)

Simplify

  y = copysign (x, positive_const_double)

to

  y = ~signbit_mask & x

and

  y = copysign (x, negative_const_double)

to

  y = signbit_mask | x

gcc/

PR target/99930
PR target/122323
* config/i386/i386-expand.cc (ix86_expand_copysign): Swap
operands[1] with operands[2].  Optimize copysign (x, const_double)
instead of copysign (const_double, x).
* config/i386/i386.md (copysign<mode>3): Swap constraints for
operands[1] and operands[2].

gcc/testsuite/

PR target/99930
PR target/122323
* gcc.target/i386/builtin-copysign-2.c: New test.
* gcc.target/i386/builtin-copysign-3.c: Likewise.
* gcc.target/i386/builtin-copysign-4.c: Likewise.
* gcc.target/i386/builtin-copysign-5.c: Likewise.
* gcc.target/i386/builtin-copysign-6.c: Likewise.
* gcc.target/i386/builtin-copysign-7.c: Likewise.
* gcc.target/i386/builtin-copysign-8a.c: Likewise.
* gcc.target/i386/builtin-copysign-8b.c: Likewise.
* gcc.target/i386/builtin-fabs-1.c: Likewise.
* gcc.target/i386/builtin-fabs-2.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit c3b0ecf04f8c14360cc02c737446c029038a95f7)

2 weeks agoDaily bump.
GCC Administrator [Fri, 24 Oct 2025 00:29:28 +0000 (00:29 +0000)] 
Daily bump.

2 weeks agotestsuite: arm: [MVE] Relax expected code for vbicq_f [PR122223]
Christophe Lyon [Thu, 23 Oct 2025 07:59:20 +0000 (07:59 +0000)] 
testsuite: arm: [MVE] Relax expected code for vbicq_f [PR122223]

The original versions of the pr122223.c test only took into account
code generated with -mfloat-abi=hard, which uses q0.

With -mfloat-abi=softfp, this can be any Q register, so replace q0
with a suitable regex.

gcc/testsuite/ChangeLog:

PR target/122223
* gcc.target/arm/mve/intrinsics/pr122223.c: Relax expected code.

(cherry picked from commit a52888dc71924afb6cd187b0e5f18d2be4c68a07)

2 weeks agoDaily bump.
GCC Administrator [Thu, 23 Oct 2025 00:27:46 +0000 (00:27 +0000)] 
Daily bump.

2 weeks agoc++: Fix up RAW_DATA_CST handling in braced_list_to_string [PR122302]
Jakub Jelinek [Wed, 22 Oct 2025 11:11:52 +0000 (13:11 +0200)] 
c++: Fix up RAW_DATA_CST handling in braced_list_to_string [PR122302]

The following testcase is miscompiled, because a RAW_DATA_CST tree
node is shared by multiple CONSTRUCTORs and when the braced_list_to_string
function changes one to extend the RAW_DATA_CST over the single preceding
and single succeeding INTEGER_CST, it changes the RAW_DATA_CST in
the other CONSTRUCTOR where the elts around it are still present.

Fixed by tweaking a copy of it instead, like we handle it in other spots.

2025-10-22  Jakub Jelinek  <jakub@redhat.com>

PR c++/122302
* c-common.cc (braced_list_to_string): Call copy_node on RAW_DATA_CST
before changing RAW_DATA_POINTER and RAW_DATA_LENGTH on it.

* g++.dg/cpp0x/pr122302.C: New test.
* g++.dg/cpp/embed-27.C: New test.

(cherry picked from commit 79b49977b1894a0a5eea3d2125eb6546b9d0cf02)

2 weeks agoi386: Correct cpu codename value for unknown model number
Haochen Jiang [Tue, 21 Oct 2025 03:21:45 +0000 (11:21 +0800)] 
i386: Correct cpu codename value for unknown model number

There are several changes for features enabled on cpus. r16-1666 disabled
CLDEMOTE on clients. r16-2224 removed Key locker since Panther Lake and
Clearwater forest. r16-4436 disabled PREFETCHI on Panther Lake.

The patches caused the current return guess value not aligned for
host_detect_local_cpu meeting the unknown model number. Correct the
logic according to the features enabled.

This patch will also backport to GCC14 and GCC15.

gcc/ChangeLog:

* config/i386/driver-i386.cc (host_detect_local_cpu): Correct
the logic for unknown model number cpu guess value.

2 weeks agoDaily bump.
GCC Administrator [Wed, 22 Oct 2025 00:28:35 +0000 (00:28 +0000)] 
Daily bump.

2 weeks agoarm: [MVE] Fix operands order in vbicq_f [PR122223]
Christophe Lyon [Thu, 9 Oct 2025 14:09:26 +0000 (14:09 +0000)] 
arm: [MVE] Fix operands order in vbicq_f [PR122223]

The operands of the floating-point version of vbicq were swapped, this
patch fixes this.

gcc/ChangeLog:
PR target/122223
* config/arm/mve.md (@mve_vbicq_f<mode>): Fix operands order.

gcc/testsuite/ChangeLog:
PR target/122223
* gcc.target/arm/mve/intrinsics/pr122223.c: New test.

(cherry picked from commit 81e226440381cc3e033df7e58cc7793c9b4b4e25)

2 weeks agoaarch64: Fix ICE when op2 is zero for SVE2 saturating add intrinsics.
Jennifer Schmitz [Thu, 21 Aug 2025 17:01:49 +0000 (10:01 -0700)] 
aarch64: Fix ICE when op2 is zero for SVE2 saturating add intrinsics.

When op2 in SVE2 saturating add intrinsics (svuqadd, svsqadd) is a zero
vector and predication is _z, an ICE in vregs occurs, e.g. for

svuint8_t foo (svbool_t pg, svuint8_t op1)
{
    return svsqadd_u8_z (pg, op1, svdup_s8 (0));
}

The insn failed to match the pattern (aarch64-sve2.md):

;; Predicated binary operations with no reverse form, merging with zero.
;; At present we don't generate these patterns via a cond_* optab,
;; so there's no correctness requirement to handle merging with an
;; independent value.
(define_insn_and_rewrite "*cond_<sve_int_op><mode>_z"
  [(set (match_operand:SVE_FULL_I 0 "register_operand")
(unspec:SVE_FULL_I
  [(match_operand:<VPRED> 1 "register_operand")
   (unspec:SVE_FULL_I
     [(match_operand 5)
      (unspec:SVE_FULL_I
[(match_operand:SVE_FULL_I 2 "register_operand")
 (match_operand:SVE_FULL_I 3 "register_operand")]
SVE2_COND_INT_BINARY_NOREV)]
     UNSPEC_PRED_X)
   (match_operand:SVE_FULL_I 4 "aarch64_simd_imm_zero")]
  UNSPEC_SEL))]
  "TARGET_SVE2"
  {@ [ cons: =0 , 1   , 2 , 3  ]
     [ &w       , Upl , 0 , w  ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
     [ &w       , Upl , w , w  ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
  }
  "&& !CONSTANT_P (operands[5])"
  {
    operands[5] = CONSTM1_RTX (<VPRED>mode);
  }
  [(set_attr "movprfx" "yes")]
)

because operands[3] and operands[4] were both expanded into the same register
operand containing a zero vector by define_expand "@cond_<sve_int_op><mode>".

This patch fixes the ICE by making a case distinction in
function_expander::use_cond_insn that uses add_fixed_operand if
fallback_arg == CONST0_RTX (mode), and otherwise add_input_operand (which was
previously the default and allowed the expansion of the zero-vector
fallback_arg to a register operand).

The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
OK for trunk?

Alex Coplan pointed out in the bugzilla ticket that this ICE goes back
to GCC 10. Shall we backport?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
Co-authored by: Richard Sandiford <rdsandiford@googlemail.com>

gcc/
PR target/121599
* config/aarch64/aarch64-sve-builtins.cc
(function_expander::use_cond_insn): Use add_fixed_operand if
fallback_arg == CONST0_RTX (mode).

gcc/testsuite/
PR target/121599
* gcc.target/aarch64/sve2/pr121599.c: New test.

2 weeks agoDaily bump.
GCC Administrator [Tue, 21 Oct 2025 00:26:07 +0000 (00:26 +0000)] 
Daily bump.

2 weeks agohurd: Add OPTION_GLIBC_P and OPTION_GLIBC
Svante Signell [Sun, 6 Feb 2022 11:43:23 +0000 (11:43 +0000)] 
hurd: Add OPTION_GLIBC_P and OPTION_GLIBC

GNU/Hurd uses glibc just like GNU/Linux.

This is needed for gcc to notice that glibc supports split stack in
finish_options.

PR go/104290
gcc/ChangeLog:
* config/gnu.h (OPTION_GLIBC_P, OPTION_GLIBC): Define.

(cherry picked from commit 29eacf043b6e8560c5c42d67f7f9b11e4e2cb156)

2 weeks agolibstdc++: Remove undeclared macros from configure.ac [PR122322]
Jonathan Wakely [Sat, 18 Oct 2025 21:05:43 +0000 (22:05 +0100)] 
libstdc++: Remove undeclared macros from configure.ac [PR122322]

The additions in r16-4443-g651bf5126da124 cause errors when running
autoreconf.

libstdc++-v3/ChangeLog:

PR libstdc++/122322
* configure.ac (with_newlib) <*-rtems*>: Remove
HAVE_SYS_IOCT4YL_H, _GLIBCXX_USE_LINK, _GLIBCXX_USE_READLINK,
_GLIBCXX_USE_SYMLINK, _GLIBCXX_USE_TRUNCATE, and
_GLIBCXX_USE_FDOPENDIR. Remove duplicates.
* configure: Regenerate.

(cherry picked from commit f5fb192c65e618508108525252b771956bdb1078)

2 weeks agolibstdc++: Fix unsafe comma operators in <random> [PR122062]
Jonathan Wakely [Thu, 25 Sep 2025 16:23:28 +0000 (17:23 +0100)] 
libstdc++: Fix unsafe comma operators in <random> [PR122062]

This fixes a 'for' loop in std::piecewise_linear_distribution that
increments two iterators with a comma operator between them, making it
vulnerable to evil overloads of the comma operator.

It also changes a 'for' loop used by some other distributions, even
though those are only used with std::vector<double>::iterator and so
won't find any overloaded commas.

libstdc++-v3/ChangeLog:

PR libstdc++/122062
* include/bits/random.tcc (__detail::__normalize): Use void cast
for operands of comma operator.
(piecewise_linear_distribution): Likewise.
* testsuite/26_numerics/random/piecewise_linear_distribution/cons/122062.cc:
New test.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
Reviewed-by: Hewill Kang <hewillk@gmail.com>
(cherry picked from commit 11ce485bcffac0db005d77e100420535e54d0aa5)

2 weeks agoAda: Fix spurious warning for renaming of component of VFA record
Eric Botcazou [Mon, 20 Oct 2025 09:21:21 +0000 (11:21 +0200)] 
Ada: Fix spurious warning for renaming of component of VFA record

This is a regression present on the mainline and all active branches: the
compiler gives a spurious "is not referenced" warning for the renaming of
a component of a Volatile_Full_Access record.

gcc/ada/
PR ada/107536
* exp_ch2.adb (Expand_Renaming): Mark the entity as referenced.

gcc/testsuite/
* gnat.dg/renaming18.adb: New test.

2 weeks agoDaily bump.
GCC Administrator [Mon, 20 Oct 2025 00:24:24 +0000 (00:24 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Sun, 19 Oct 2025 00:23:36 +0000 (00:23 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Sat, 18 Oct 2025 00:25:03 +0000 (00:25 +0000)] 
Daily bump.

3 weeks agox86: Cast stride to __PTRDIFF_TYPE__ for AMX-MOVRS intrinsics. [PR122119]
Hu, Lin1 [Fri, 10 Oct 2025 06:30:19 +0000 (14:30 +0800)] 
x86: Cast stride to __PTRDIFF_TYPE__ for AMX-MOVRS intrinsics. [PR122119]

On 64-bit windows, long can't be used, because it is 32 bits. Use
__PTRDIFF_TYPE__ instead of long.

gcc/ChangeLog:

PR target/122119
* config/i386/amxmovrsintrin.h
(_tile_loaddrs_internal): Use __PTRDIFF_TYPE__ instead of long.
(_tile_loaddrst1_internal): Ditto.
(_tile_2rpntlvwz0rs_internal): Ditto.
(_tile_2rpntlvwz0rst1_internal): Ditto.
(_tile_2rpntlvwz1rs_internal): Ditto.
(_tile_2rpntlvwz1rst1_internal): Ditto.

3 weeks agoDaily bump.
GCC Administrator [Fri, 17 Oct 2025 00:23:52 +0000 (00:23 +0000)] 
Daily bump.

3 weeks agoError out stack-protector unavailability on AIX
Ayappan Perumal [Mon, 1 Sep 2025 13:27:52 +0000 (08:27 -0500)] 
Error out stack-protector unavailability on AIX

stack-protector is not supported in GCC on AIX. This patch is to fail the
compilation if -fstack-protector option is passed.

gcc/ChangeLog:

* config/rs6000/aix.h (SUBTARGET_DRIVER_SELF_SPECS):
Error out when stack-protector option is used in AIX
as it is not supported on AIX

Approved By: Segher Boessenkool <segher@kernel.crashing.org>

(cherry picked from commit dfb7e97dd214f7d8ca0fa970d81ad5ba805aaa8d)

3 weeks agoDaily bump.
GCC Administrator [Thu, 16 Oct 2025 00:27:45 +0000 (00:27 +0000)] 
Daily bump.

3 weeks agolibstdc++-v3: Enable features for RTEMS (based on GCC 15)
Chris Johns [Fri, 30 May 2025 21:14:02 +0000 (16:14 -0500)] 
libstdc++-v3: Enable features for RTEMS (based on GCC 15)

libstdc++-v3/ChangeLog:

* configure: Regenerate.
* configure.ac (newlib, *-rtems*): Add HAVE_SYS_IOCTL_H,
HAVE_SYS_STAT_H, HAVE_SYS_TYPES_H, HAVE_S_ISREG, HAVE_UNISTD_H,
HAVE_UNLINKAT, _GLIBCXX_USE_CHMOD, _GLIBCXX_USE_MKDIR,
_GLIBCXX_USE_CHDIR, _GLIBCXX_USE_GETCWD, _GLIBCXX_USE_UTIME,
_GLIBCXX_USE_LINK, _GLIBCXX_USE_READLINK, _GLIBCXX_USE_SYMLINK,
_GLIBCXX_USE_TRUNCATE and _GLIBCXX_USE_FDOPENDIR.

3 weeks agoaarch64: Fix pmsdsfr_el1 encoding
Alice Carlotti [Wed, 15 Oct 2025 13:14:43 +0000 (14:14 +0100)] 
aarch64: Fix pmsdsfr_el1 encoding

The encoding was fixed in Binutils in May 2024, but we didn't copy the
fix to GCC at the time.

gcc/ChangeLog:

* config/aarch64/aarch64-sys-regs.def: Fix pmsdsfr_el1 encoding.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/rwsr-armv8p9.c: Fix pmsdsfr_el1
encoding.

3 weeks agoaarch64, testsuite: Add -fchecking to test options [PR121772]
Alex Coplan [Mon, 13 Oct 2025 13:41:09 +0000 (13:41 +0000)] 
aarch64, testsuite: Add -fchecking to test options [PR121772]

I noticed while testing a backport of the PR121772 fix to GCC 13 that
the test wasn't triggering the ICE as expected with the unpatched
compiler.

This turned out to be because the ICE is a checking ICE, and we
configure by default with --enable-checking=release on the branches.
Additionally, I hadn't noticed when doing the backports to 15 and 14
since there we still ICE later on in emit_move_insn even if we don't
catch the invalid gimple with checking.

I'm not too sure why the 13 branch doesn't see the emit_move_insn ICE,
but it's somewhat irrelevant - the important thing is that adding
-fchecking to the options makes the test fail as expected with an
unpatched compiler (i.e. with a gimple checking failure), even on
release branches.

I considered applying this patch to just the release branches, but
figured that trunk will at some point itself become a release branch, so
it seems to make most sense just to apply it everywhere.

I've checked that the test still passes with this patch, and still fails
if I revert the PR121772 fix.

gcc/testsuite/ChangeLog:

PR tree-optimization/121772
* gcc.target/aarch64/torture/pr121772.c: Add -fchecking to
dg-options.

(cherry picked from commit 0c670d38455c788ac0447e3b86ba621521d44bce)

3 weeks agoi386: Correct ISA set for Panther Lake and Diamond Rapids
Haochen Jiang [Wed, 15 Oct 2025 06:05:07 +0000 (14:05 +0800)] 
i386: Correct ISA set for Panther Lake and Diamond Rapids

In ISE, Panther Lake does not enable PREFETCHI and Diamond Rapids
does not enable USER_MSR. Correct them accordingly.

I will backport the patch to GCC15/14. For GCC14, only PTL will be
backported.

gcc/ChangeLog:

* config/i386/i386.h
(PTA_PANTHERLAKE): Remove PREFETCHI.
(PTA_DIAMONDRAPIDS): Remove USER_MSR.
* doc/invoke.texi: Correct documentation.

3 weeks agoDaily bump.
GCC Administrator [Wed, 15 Oct 2025 00:28:35 +0000 (00:28 +0000)] 
Daily bump.

3 weeks agoc++: pointer to auto member function [PR120757]
Jason Merrill [Wed, 20 Aug 2025 03:15:20 +0000 (23:15 -0400)] 
c++: pointer to auto member function [PR120757]

Here r13-1210 correctly changed &A<int>::foo to not be considered
type-dependent, but tsubst_expr of the OFFSET_REF got confused trying to
tsubst a type that involved auto.  Fixed by getting the type from the
member rather than tsubst.

PR c++/120757

gcc/cp/ChangeLog:

* pt.cc (tsubst_expr) [OFFSET_REF]: Don't tsubst the type.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/auto-fn66.C: New test.

(cherry picked from commit ea6ef13d0fc4e020d8c405333153dad9eee1f18d)

3 weeks agogimplify: Fix up side-effect handling in 2nd __builtin_c[lt]zg argument [PR122188]
Jakub Jelinek [Thu, 9 Oct 2025 16:06:39 +0000 (18:06 +0200)] 
gimplify: Fix up side-effect handling in 2nd __builtin_c[lt]zg argument [PR122188]

The patch from yesterday made me think about side-effects in the second
argument of __builtin_c[lt]zg.  When we change
__builtin_c[lt]zg (x, y)
when y is not INTEGER_CST into
x ? __builtin_c[lt]zg (x) : y
with evaluating x only once, we omit the side-effects in y unless x is not
0.  That looks undesirable, we should evaluate side-effects in y
unconditionally.

2025-10-09  Jakub Jelinek  <jakub@redhat.com>

PR c/122188
* c-gimplify.cc (c_gimplify_expr): Also gimplify the second operand
before the COND_EXPR and use in COND_EXPR result of gimplification.

* gcc.dg/torture/pr122188.c: New test.

(cherry picked from commit 579de8f5295b05573d05f6e4102f1428f35c9f17)

3 weeks agogimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]
Jakub Jelinek [Wed, 8 Oct 2025 07:58:41 +0000 (09:58 +0200)] 
gimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]

The following testcase ICEs during gimplification.
The problem is that save_expr sometimes doesn't create a SAVE_EXPR but
returns the original complex tree (COND_EXPR) and the code then uses that
tree in 2 different spots without unsharing.  As this is done during
gimplification it wasn't unshared when whole body is unshared and because
gimplification is destructive, the first time we gimplify it we destruct it
and second time we try to gimplify it we ICE on it.
Now, we could replace one a use with unshare_expr (a), but because this
is a gimplification hook, I think easier than trying to create a save_expr
is just gimplify the argument, then we know it is is_gimple_val and so
something without side-effects and can safely use it twice.  That argument
would be the first thing to gimplify after return GS_OK anyway, so it
doesn't change argument sequencing etc.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR c/122188
* c-gimplify.cc (c_gimplify_expr): Gimplify CALL_EXPR_ARG (*expr_p, 0)
instead of calling save_expr on it.

* c-c++-common/pr122188.c: New test.

(cherry picked from commit bb22f7d4d63446c9095db32ca013a9b2182df7d9)

3 weeks agostmt: Handle %cc[name] in resolve_asm_operand_names [PR122133]
Jakub Jelinek [Mon, 6 Oct 2025 07:46:48 +0000 (09:46 +0200)] 
stmt: Handle %cc[name] in resolve_asm_operand_names [PR122133]

Last year I've extended the asm template syntax in inline asm to support
%cc0 etc., apparently the first 2 letter generic operand modifier.
As the following testcase shows, I forgot to tweak the [foo] handling
for it though.  As final.cc will error on any % ISALPHA not followed by
digit (with the exception of % c c digit), I think we can safely handle
this for any 2 letters in between % and [, instead of hardcoding it for
now only for %cc[ and changing it again next time we add something
two-letter.

2025-10-06  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/122133
* stmt.cc (resolve_asm_operand_names): Handle % and 2 letters followed
by open square.

* c-c++-common/toplevel-asm-9.c: New test.

(cherry picked from commit 96c4a32cfec8c4b4c677de114164192cfd8ae54d)

3 weeks agowidening_mul: Reset flow sensitive info in maybe_optimize_guarding_check [PR122104]
Jakub Jelinek [Sat, 4 Oct 2025 15:06:16 +0000 (17:06 +0200)] 
widening_mul: Reset flow sensitive info in maybe_optimize_guarding_check [PR122104]

In PR95852 I've added an optimization where next to just pattern
recognizing r = x * y; r / x != y or r = x * y; r / x == y
as .MUL_OVERFLOW or negation thereof it also recognizes
r = x * y; x && (r / x != y) or r = x * y; !x || (r / x == y)
by optimizing the guarding condition to always true/false.

The problem with that is that some value ranges recorded for
the SSA_NAMEs in the formerly conditional, now unconditional
basic block can be invalid.

This patch fixes it by calling reset_flow_sensitive_info_in_bb
if we optimize the guarding condition.

2025-10-04  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/122104
* tree-ssa-math-opts.cc (maybe_optimize_guarding_check): Call
reset_flow_sensitive_info_in_bb on bb when optimizing out the
guarding condition.

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

(cherry picked from commit 867f777cee9f44027a3724fbad266c5cfb3a311f)

3 weeks agoi386: Remove AMX-TRANSPOSE from Diamond Rapids
Haochen Jiang [Tue, 1 Jul 2025 06:11:55 +0000 (14:11 +0800)] 
i386: Remove AMX-TRANSPOSE from Diamond Rapids

AMX-TRANSPOSE will be removed from Diamond Rapids according to ISE.
Backported from trunk AMX-TRANSPOSE removal patch.

gcc/ChangeLog:

* config/i386/i386.h (PTA_DIAMONDRAPIDS): Remove AMX-TRANSPOSE.
* doc/invoke.texi: Correct documentation.

3 weeks agoDaily bump.
GCC Administrator [Tue, 14 Oct 2025 00:27:12 +0000 (00:27 +0000)] 
Daily bump.

3 weeks agomatch.pd: Do not canonicalize division by power 2 for {ROUND, CEIL}_DIV
Avinash Jayakar [Mon, 13 Oct 2025 09:47:45 +0000 (15:17 +0530)] 
match.pd: Do not canonicalize division by power 2 for {ROUND, CEIL}_DIV

Canonicalization of unsigned division by power of 2 only applies to
{TRUNC,FLOOR,EXACT}_DIV, therefore remove the same pattern for {CEIL,ROUND}_DIV,
which was added in a previous commit.

2025-10-13  Avinash Jayakar  <avinashd@linux.ibm.com>

gcc/ChangeLog:
PR tree-optimization/122213
* match.pd: Canonicalize unsigned pow2 div only for trunk, floor and
exact div.

3 weeks agoDaily bump.
GCC Administrator [Mon, 13 Oct 2025 00:24:32 +0000 (00:24 +0000)] 
Daily bump.

3 weeks agoDaily bump.
GCC Administrator [Sun, 12 Oct 2025 00:24:54 +0000 (00:24 +0000)] 
Daily bump.

3 weeks ago[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].
Robin Dapp [Tue, 7 Oct 2025 13:18:27 +0000 (07:18 -0600)] 
[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].

Hi,

In shuffle_series_pattern we use series_p to determine if the permute
mask is a simple series.  This didn't take into account that series_p
also returns true for e.g. {0, 3, 2, 1} where the step is 3 and the
indices form a series modulo 4.

We emit
 vid + vmul
in order to synthesize a series.  In order to be always correct we would
need a vrem afterwards still which does not seem worth it.

This patch adds the modulo for VLA permutes and punts if we wrap around
for VLS permutes.  I'm not really certain whether we'll really see a wrapping
VLA series (certainly we haven't so far in the test suite) but as we observed
a VLS one here now it appears conservatively correct to module the indices.

Regtested on rv64gcv_zvl512b.

Regards
 Robin

PR target/121845

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_series_patterns):
Modulo indices for VLA and punt when wrapping for VLS.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr121845.c: New test.

(cherry picked from commit 62631c39a788161ff2f686adf355d10443e0d899)

3 weeks agoDaily bump.
GCC Administrator [Sat, 11 Oct 2025 00:26:18 +0000 (00:26 +0000)] 
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Fri, 10 Oct 2025 00:28:00 +0000 (00:28 +0000)] 
Daily bump.

4 weeks agoAVR: target/122222 - Add modules for __floatsidf, __floatunsidf.
Georg-Johann Lay [Thu, 9 Oct 2025 16:35:34 +0000 (18:35 +0200)] 
AVR: target/122222 - Add modules for __floatsidf, __floatunsidf.

PR target/122222
libgcc/config/avr/libf7/
* libf7-asm.sx (D_floatsidf, D_floatunsidf): New modules.
* libf7-common.mk (F7_ASM_PARTS): Add D_floatsidf, D_floatunsidf.
(F7F, g_dx): Remove floatunsidf, floatsidf.
* libf7.c (f7_set_s32): Don't alias to f7_floatsidf.
(f7_set_u32): Don't alias to f7_floatunsidf.
* f7-renames.h: Rebuild
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/pr122222-sitod.c: New test.

(cherry picked from commit 078208cf15bb373dc7931d6b373689cdff70cdc5)

4 weeks agoAVR: target/122220 - Let (int32_t) -0x1p31L return INT32_MIN.
Georg-Johann Lay [Thu, 9 Oct 2025 13:27:16 +0000 (15:27 +0200)] 
AVR: target/122220 - Let (int32_t) -0x1p31L return INT32_MIN.

PR target/122220
libgcc/config/avr/libf7/
* libf7-asm.sx (to_integer): Return 0x80... on negative overflow.

gcc/testsuite/
* gcc.target/avr/pr122220.c: New test.

(cherry picked from commit 3ea09e4d43278aa8d7b088a5f5438d921c48c411)

4 weeks agoAVR: target/122210 - Add double -> fixed-point conversions.
Georg-Johann Lay [Wed, 8 Oct 2025 18:02:53 +0000 (20:02 +0200)] 
AVR: target/122210 - Add double -> fixed-point conversions.

PR target/122210
libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add D2<fx> modules.
* libf7-asm.sx: Implement the D2<fx> modules.

gcc/testsuite/
* gcc.target/avr/dtofx.c: New test.

(cherry picked from commit b0bc615d9374ca6293996cf3afca8cabaca0defd)

4 weeks agoAVR: target/122210 - Add fixed-point -> double conversions.
Georg-Johann Lay [Wed, 8 Oct 2025 18:02:53 +0000 (20:02 +0200)] 
AVR: target/122210 - Add fixed-point -> double conversions.

PR target/122210
libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add <fx>2D modules.
* libf7-asm.sx: Implement the <fx>2D modules.

gcc/testsuite/
* gcc.target/avr/fxtod.c: New test.

(cherry picked from commit 7304e83f1f29c39df7a9de888d9c6d40b58c512a)

4 weeks agoDaily bump.
GCC Administrator [Thu, 9 Oct 2025 00:28:11 +0000 (00:28 +0000)] 
Daily bump.

4 weeks ago[PATCH v2] RISC-V: fix __builtin_round NaN handling [PR target/121652]
Aurelien Jarno [Thu, 2 Oct 2025 15:05:34 +0000 (09:05 -0600)] 
[PATCH v2] RISC-V: fix __builtin_round NaN handling [PR target/121652]

__builtin_round() fails to correctly generate invalid exceptions for NaN
inputs when -ftrapping-math is used (which is the default). According to
the specification, an invalid exception should be raised for sNaN, but
not for qNaN.

Commit f12a27216952 ("RISC-V: fix __builtin_round clobbering FP...")
attempted to avoid raising an invalid exception for qNaN by saving and
restoring the FP exception flags. However this inadvertently suppressed
the invalid exception for sNaN as well.

Instead of saving/restoring fflags, this patch uses the same approach
than the well tested GLIBC round implementation. When flag_trapping_math
is enabled, it first checks whether the input is a NaN using feq.s/d. In
that case it adds the input value with itself to possibly convert sNaN
into qNaN. With this change, the glibc testsuite passes again.

The generated code with -ftrapping-math now looks like:

convert_float_to_float_round
  feq.s       a5,fa0,fa0
  beqz        a5,.L6
  auipc       a5,0x0
  flw         fa4,42(a5)
  fabs.s      fa5,fa0
  flt.s       a5,fa5,fa4
  beqz        a5,.L5
  fcvt.w.s    a5,fa0,rmm
  fcvt.s.w    fa5,a5
  fsgnj.s     fa0,fa5,fa0
  ret
.L6:
  fadd.s      fa0,fa0,fa0
.L5:
  ret

With -fno-trapping-math, the additional checks are omitted so the
resulting code is unchanged.

In addition this fixes the following failures:
FAIL: gcc.target/riscv/rvv/autovec/vls/math-nearbyint-1.c -O3 -ftree-vectorize -mrvv-vector-bits=scalable  scan-assembler-times frflags\\s+[atx][0-9]+ 32
FAIL: gcc.target/riscv/rvv/autovec/vls/math-nearbyint-1.c -O3 -ftree-vectorize -mrvv-vector-bits=scalable  scan-assembler-times fsflags\\s+[atx][0-9]+ 32

Fixes: f652a35877e3 ("This is almost exclusively Jivan's work....")
Fixes: f12a27216952 ("RISC-V: fix __builtin_round clobbering FP...")
PR target/121652

gcc/ChangeLog:

* config/riscv/riscv.md (round_pattern): special case NaN input
instead of saving/restoring fflags.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/math-nearbyint-1.c: Adjust
scan pattern for fewer instances of frflags/fsrflags.

(cherry picked from commit 60c6f92fb192352d784ab3153a9e11c19a3216a0)

4 weeks agoDaily bump.
GCC Administrator [Wed, 8 Oct 2025 00:27:03 +0000 (00:27 +0000)] 
Daily bump.

4 weeks agoAVR: target/122187 - Don't clobber recog_data.operand[] in insn out.
Georg-Johann Lay [Tue, 7 Oct 2025 15:50:34 +0000 (17:50 +0200)] 
AVR: target/122187 - Don't clobber recog_data.operand[] in insn out.

avr.cc::avr_out_extr() and avr.cc::avr_out_extr_not()
changed xop for output, which spoiled the operand for
the next invokation, running into an assertion.

This patch makes a local copy of the operands.

PR target/122187
gcc/
* config/avr/avr.cc (avr_out_extr, avr_out_extr_not):
Make a local copy of the passed rtx[] operands.

gcc/testsuite/
* gcc.target/avr/torture/pr122187.c: New test.

(cherry picked from commit 3cbd43d640d6384df85c171a0245488f0adc3145)

4 weeks agoDaily bump.
GCC Administrator [Tue, 7 Oct 2025 00:27:45 +0000 (00:27 +0000)] 
Daily bump.

4 weeks agoAVR/LibF7: Implement sincos.
Georg-Johann Lay [Mon, 6 Oct 2025 19:31:46 +0000 (21:31 +0200)] 
AVR/LibF7: Implement sincos.

libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add D_sincos.
* libf7-asm.sx: (D_sincos): New module implements sincos / sincosl.

gcc/testsuite/
* gcc.target/avr/sincos-1.c: New test.

(cherry picked from commit e3a05e050226aaaa4e2a2e7aee1e5651212a68f6)

4 weeks agoAVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.
Georg-Johann Lay [Sun, 5 Oct 2025 18:56:56 +0000 (20:56 +0200)] 
AVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.

fmin and fmax should return the non-NaN argument in the case where
exactly one argument is a NaN.

Moreover, IEEE double fmin and fmax can be performed without
first converting the args to the internal representation and
then converting back again.

PR target/122177
libgcc/config/avr/libf7/
* libf7-common.mk (m_ddd): Remove: fmin, fmax.
(F7_ASM_PARTS): Add: D_fminfmax.
* libf7-asm.sx (D_fmanfmax): New module.
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/fminfmax-1.c: New test.

(cherry picked from commit efb3cd64fdefab88c7787b16ad33be33f4c4a2a4)

4 weeks agoAVR: Speed up IEEE double comparisons.
Georg-Johann Lay [Sun, 5 Oct 2025 18:56:56 +0000 (20:56 +0200)] 
AVR: Speed up IEEE double comparisons.

IEEE double can be compared without first converting them to
the internal representation.

libgcc/config/avr/libf7/
* libf7-common.mk (g_xdd_cmp): Remove le, lt, ge, gt, ne, eq, unord.
(F7_ASM_PARTS): Add D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord.
* libf7-asm.sx (D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord):
New modules.
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/cmpdi-1.c: New test.

(cherry picked from commit e5731a4bc50e95245cb628505142e0adff0bb79e)

4 weeks agoDaily bump.
GCC Administrator [Mon, 6 Oct 2025 00:23:58 +0000 (00:23 +0000)] 
Daily bump.

4 weeks agoDaily bump.
GCC Administrator [Sun, 5 Oct 2025 16:56:15 +0000 (16:56 +0000)] 
Daily bump.

4 weeks agoAdd testcase for PR ada/113536
Eric Botcazou [Sun, 5 Oct 2025 08:42:25 +0000 (10:42 +0200)] 
Add testcase for PR ada/113536

gcc/testsuite/
PR ada/113536
* gnat.dg/reduce2.adb: New test.

4 weeks agoAda: Remove useless Makefile variable
Eric Botcazou [Sun, 5 Oct 2025 08:25:14 +0000 (10:25 +0200)] 
Ada: Remove useless Makefile variable

gcc/ada
PR ada/118343
* Makefile.rtl (LLVM_BUILD): Delete.

5 weeks agoRISC-V: Use correct target in expand_vec_perm [PR121780].
Robin Dapp [Thu, 4 Sep 2025 08:16:21 +0000 (10:16 +0200)] 
RISC-V: Use correct target in expand_vec_perm [PR121780].

This fixes a glaring mistake in yesterday's change to the expansion of
vec_perm.  We should of course move tmp_target into the real target
and not the other way around.  I wonder why my testing hasn't
caught this...

PR target/121742
PR target/121780
PR target/121781

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vec_perm): Swap target and
tmp_target.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr121780.c: New test.
* gcc.target/riscv/rvv/autovec/pr121781.c: New test.

(cherry picked from commit e3d5e9f0c8c6f27bf59d321d5082be7b3bb39f8a)

5 weeks agoRISC-V: Handle overlap in expand_vec_perm PR121742.
Robin Dapp [Mon, 1 Sep 2025 09:41:34 +0000 (11:41 +0200)] 
RISC-V: Handle overlap in expand_vec_perm PR121742.

In a two-source gather we unconditionally overwrite target with the
first gather's result already.  If op1 == target this clobbers the
source operand for the second gather.  This patch uses a temporary in
that case.

PR target/121742

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vec_perm): Use temporary if
op1 and target overlap.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr121742.c: New test.

(cherry picked from commit f957d352bd6f240829226405e9be7960071d1b9c)

5 weeks agoRISC-V: Always register vector built-in functions during LTO [PR110812]
Kito Cheng [Thu, 10 Jul 2025 07:28:30 +0000 (15:28 +0800)] 
RISC-V: Always register vector built-in functions during LTO [PR110812]

Previously, vector built-in functions were not properly registered during
the LTO pipeline, causing link failures when vector intrinsics were used
in LTO builds with mixed architecture options.  This patch ensures all
vector built-in functions are always registered during LTO compilation.

The key changes include:
- Moving pragma intrinsic flag manipulation from riscv-c.cc to
  riscv-vector-builtins.cc for better encapsulation
- Registering all vector built-in functions regardless of current ISA
  extensions, deferring the actual extension checking to expansion time
- Adding proper support for built-in type registration during LTO

This approach is safe because we already perform extension requirement
checking at expansion time.  The trade-off is a slight increase in
bootstrap time for LTO builds due to registering more built-in functions.

PR target/110812

gcc/ChangeLog:

* config/riscv/riscv-c.cc (pragma_intrinsic_flags): Remove struct.
(riscv_pragma_intrinsic_flags_pollute): Remove function.
(riscv_pragma_intrinsic_flags_restore): Remove function.
(riscv_pragma_intrinsic): Simplify to only call handle_pragma_vector.
* config/riscv/riscv-vector-builtins.cc (pragma_intrinsic_flags):
Move struct definition here from riscv-c.cc.
(riscv_pragma_intrinsic_flags_pollute): Move and adapt from
riscv-c.cc, add zvfbfmin, zvfhmin and vector_elen_bf_16 support.
(riscv_pragma_intrinsic_flags_restore): Move from riscv-c.cc.
(rvv_switcher::rvv_switcher): Add pollute_flags parameter to
control flag manipulation.
(rvv_switcher::~rvv_switcher): Restore flags conditionally.
(register_builtin_types): Use rvv_switcher without polluting flags.
(get_required_extensions): Remove function.
(check_required_extensions): Simplify to only check type validity.
(function_instance::function_returns_void_p): Move implementation
from header.
(function_builder::add_function): Register placeholder for LTO.
(init_builtins): Simplify and handle LTO case.
(reinit_builtins): Remove function.
(handle_pragma_vector): Remove extension checking.
* config/riscv/riscv-vector-builtins.h
(function_instance::function_returns_void_p): Add declaration.
(function_call_info::function_returns_void_p): Remove inline
implementation.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/lto/pr110812_0.c: New test.
* gcc.target/riscv/lto/pr110812_1.c: New test.
* gcc.target/riscv/lto/riscv-lto.exp: New test driver.
* gcc.target/riscv/lto/riscv_vector.h: New header wrapper.

5 weeks agoDaily bump.
GCC Administrator [Thu, 2 Oct 2025 00:26:28 +0000 (00:26 +0000)] 
Daily bump.

5 weeks agoDaily bump.
GCC Administrator [Wed, 1 Oct 2025 00:27:56 +0000 (00:27 +0000)] 
Daily bump.

5 weeks agoAda: Fix internal error on ill-formed Reduce attribute in Ada 2022
Eric Botcazou [Tue, 30 Sep 2025 09:55:18 +0000 (11:55 +0200)] 
Ada: Fix internal error on ill-formed Reduce attribute in Ada 2022

This is an internal error on the new Reduce attribute of Ada 2022 when the
programmer swaps its arguments(!)  The change makes it so that the compiler
gives an error message instead.

gcc/ada/
PR ada/117517
* sem_attr.adb (Resolve_Attribute) <Attribute_Reduce>: Try to
resolve the reducer first.  Fix casing of error message.

gcc/testsuite/
* gnat.dg/reduce1.adb: New test.

5 weeks agoDaily bump.
GCC Administrator [Tue, 30 Sep 2025 00:27:22 +0000 (00:27 +0000)] 
Daily bump.

5 weeks agoDaily bump.
GCC Administrator [Mon, 29 Sep 2025 00:25:02 +0000 (00:25 +0000)] 
Daily bump.

5 weeks agoFortran: fix assignment to allocatable scalar polymorphic component [PR121616]
Harald Anlauf [Thu, 11 Sep 2025 18:17:31 +0000 (20:17 +0200)] 
Fortran: fix assignment to allocatable scalar polymorphic component [PR121616]

PR fortran/121616

gcc/fortran/ChangeLog:

* primary.cc (gfc_variable_attr): Properly set dimension attribute
from a component ref.

gcc/testsuite/ChangeLog:

* gfortran.dg/alloc_comp_assign_17.f90: New test.

(cherry picked from commit 0899b826f7196f609fc8991456eb728802061318)

5 weeks agoFortran: ICE in character(kind=4) deferred-length array reference [PR121939]
Harald Anlauf [Wed, 24 Sep 2025 18:57:21 +0000 (20:57 +0200)] 
Fortran: ICE in character(kind=4) deferred-length array reference [PR121939]

PR fortran/121939

gcc/fortran/ChangeLog:

* trans-types.cc (gfc_init_types): Set string flag for all
character types.

gcc/testsuite/ChangeLog:

* gfortran.dg/deferred_character_39.f90: Disable temporary
workaround for character(kind=4) deferred-length bug.

(cherry picked from commit 43508d358b9e53abfc3be4e28accbd4a07154dfc)

5 weeks agoFortran: fix issues with rank-2 deferred-length character arrays [PR108581]
Harald Anlauf [Sat, 20 Sep 2025 20:20:25 +0000 (22:20 +0200)] 
Fortran: fix issues with rank-2 deferred-length character arrays [PR108581]

PR fortran/108581

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_expr_descriptor): Take the dynamic
string length into account when deriving the dataptr offset for
a deferred-length character array.

gcc/testsuite/ChangeLog:

* gfortran.dg/deferred_character_39.f90: New test.

(cherry picked from commit 749af11149623dbf9ba026fd98bd7f31409fdaed)

5 weeks agoDaily bump.
GCC Administrator [Sun, 28 Sep 2025 00:25:46 +0000 (00:25 +0000)] 
Daily bump.

5 weeks agoDaily bump.
GCC Administrator [Sat, 27 Sep 2025 00:25:33 +0000 (00:25 +0000)] 
Daily bump.

6 weeks agoLoongArch: Implement TARGET_CAN_INLINE_P[PR121875].
Lulu Cheng [Wed, 24 Sep 2025 06:49:53 +0000 (14:49 +0800)] 
LoongArch: Implement TARGET_CAN_INLINE_P[PR121875].

Because LoongArch does not implement TARGET_CAN_INLINE_P,
functions with the target attribute set and those without
it cannot be inlined.  At the same time, setting the
always_inline attribute will cause compilation failure.

To solve this problem, I implemented this hook. During the
implementation process, it checks the status of the target
special options of the caller and callee, such as the ISA
extension.

PR target/121875

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_can_inline_p): New function.
(TARGET_CAN_INLINE_P): Define.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/can_inline_1.c: New test.
* gcc.target/loongarch/can_inline_2.c: New test.
* gcc.target/loongarch/can_inline_3.c: New test.
* gcc.target/loongarch/can_inline_4.c: New test.
* gcc.target/loongarch/can_inline_5.c: New test.
* gcc.target/loongarch/can_inline_6.c: New test.
* gcc.target/loongarch/pr121875.c: New test.

(cherry picked from commit d6ee89a65bd98b14940245ec79814ae3d38b0121)

6 weeks agoDaily bump.
GCC Administrator [Fri, 26 Sep 2025 00:25:10 +0000 (00:25 +0000)] 
Daily bump.

6 weeks agomatch.pd: Add missing type check to reduc(ctor) pattern [PR121772]
Alex Coplan [Tue, 9 Sep 2025 11:57:14 +0000 (12:57 +0100)] 
match.pd: Add missing type check to reduc(ctor) pattern [PR121772]

In this PR we have a reduction of a vector constructor, where the
type of the constructor is int16x8_t and the elements are int16x4_t;
i.e. it is representing a concatenation of two vectors.

This triggers a match.pd pattern which looks like it was written to
handle reductions of vector constructors where the elements of the ctor
are scalars, not vectors.  There is no type check to enforce this
property, which leads to the pattern replacing a reduction to scalar
with an int16x4_t vector in this case, which of course is a type error,
leading to an invalid GIMPLE ICE.

This patch adds a type check to the pattern, only going ahead with the
transformation if the element type of the ctor matches that of the
reduction.

gcc/ChangeLog:

PR tree-optimization/121772
* match.pd: Add type check to reduc(ctor) pattern.

gcc/testsuite/ChangeLog:

PR tree-optimization/121772
* gcc.target/aarch64/torture/pr121772.c: New test.

(cherry picked from commit a7a9b7badc0ba95b510c7e61da6439fca78e31d3)

6 weeks agoc++/modules: Remove incorrect assertion [PR122015,PR122019]
Nathaniel Shead [Thu, 25 Sep 2025 11:05:40 +0000 (21:05 +1000)] 
c++/modules: Remove incorrect assertion [PR122015,PR122019]

This assertion, despite what I said in r16-4070, is not valid: we can
reach here when deduping a VAR_DECL that didn't get a LANG_SPECIFIC in
the current TU.  It's still correct to always use lang_cplusplus however
as for anything else the decl would have been created with an
appropriate LANG_SPECIFIC to start with.

PR c++/122015
PR c++/122019

gcc/cp/ChangeLog:

* module.cc (trees_in::install_entity): Remove incorrect
assertion.

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

6 weeks agoOpenMP: Unshare expr in context-selector condition [PR121922]
Tobias Burnus [Thu, 18 Sep 2025 09:07:50 +0000 (11:07 +0200)] 
OpenMP: Unshare expr in context-selector condition [PR121922]

As the testcase shows, a missing unshare_expr caused that the condition
was only evaluated once instead of every time when a 'declare variant'
was resolved.

PR middle-end/121922

gcc/ChangeLog:

* omp-general.cc (omp_dynamic_cond): Use 'unshare_expr' for
the user condition.

libgomp/ChangeLog:

* testsuite/libgomp.c-c++-common/declare-variant-1.c: New test.

Co-authored-by: Sandra Loosemore <sloosemore@baylibre.com>
(cherry picked from commit 97c1d2fa97afc59b02d2894b88069136145603e2)

6 weeks agoDaily bump.
GCC Administrator [Thu, 25 Sep 2025 00:28:17 +0000 (00:28 +0000)] 
Daily bump.

6 weeks agolibstdc++/testsuite: Unpoison 'u' on s390x in names.cc test
Patrick Palka [Wed, 24 Sep 2025 02:41:26 +0000 (22:41 -0400)] 
libstdc++/testsuite: Unpoison 'u' on s390x in names.cc test

This is the s390 counterpart to r11-7364-gd0453cf5c68b6a, and fixes the
following names.cc failure caused by a use of a poisoned identifier.
If we look at the corresponding upstream header[1] it's clear that the
problematic identifier is 'u'.

In file included from /usr/include/linux/types.h:5,
                 from /usr/include/linux/sched/types.h:5,
                 from /usr/include/bits/sched.h:61,
                 from /usr/include/sched.h:43,
                 from /usr/include/pthread.h:22,
                 from /usr/include/c++/14/s390x-redhat-linux/bits/gthr-default.h:35,
                 from /usr/include/c++/14/s390x-redhat-linux/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/c++/14/s390x-redhat-linux/bits/stdc++.h:54,
                 from /root/rpmbuild/BUILD/gcc-14.3.1-20250617/libstdc++-v3/testsuite/17_intro/names.cc:384:
/usr/include/asm/types.h:24: error: expected unqualified-id before '[' token
/usr/include/asm/types.h:24: error: expected ')' before '[' token
/root/rpmbuild/BUILD/gcc-14.3.1-20250617/libstdc++-v3/testsuite/17_intro/names.cc:101: note: to match this '('
compiler exited with status 1
FAIL: 17_intro/names.cc  -std=gnu++98 (test for excess errors)
Excess errors:
/usr/include/asm/types.h:24: error: expected unqualified-id before '[' token
/usr/include/asm/types.h:24: error: expected ')' before '[' token

[1]: https://github.com/torvalds/linux/blob/master/arch/s390/include/uapi/asm/types.h

libstdc++-v3/ChangeLog:

* testsuite/17_intro/names.cc: Undefine 'u' on s390*-linux.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit e9f3138f38067664bae25947ebabc0e8fa223d43)

6 weeks agoc++: find_template_parameters and NTTPs [PR121981]
Patrick Palka [Sat, 20 Sep 2025 14:45:22 +0000 (10:45 -0400)] 
c++: find_template_parameters and NTTPs [PR121981]

Here the normal form of the two immediately-declared D<<placeholder>, V>
constraints is the same, so we rightfully share the normal form between
them.  We first compute the normal form from the context of auto deduction
for W in which case the placeholder has level 2 where the set of
in-scope template parameters has depth 2 (a dummy level is added from
normalize_placeholder_type_constraints).

Naturally the atomic constraint only depends on the template parameter
V of depth 1 index 0.  The depth 2 of current_template_parms however
means that find_template_parameters when it sees V within the atomic
constraint will recurse into its TREE_TYPE, an auto of level 2, and mark
the atomic constraint as also depending on the template parameter of
depth 2 index 0, which is clearly wrong.  Later during constraint
checking for B we ICE within the satisfaction cache since we lack two
levels of template arguments supposedly needed by the cached atomic
constraint.

I think when find_template_parameters sees an NTTP, it doesn't need to
walk its TREE_TYPE because NTTP substitution is done obliviously with
respect to its type -- only the corresponding NTTP argument matters,
not other template arguments possibly used within its type.  This is
most clearly true for (unconstrained) auto NTTPs as in the testcase, but
also true for other NTTPs.  Doing so fixes the testcase because we no
longer record any depth 2 when walking V within the atomic constraint.

PR c++/121981

gcc/cp/ChangeLog:

* pt.cc (any_template_parm_r) <case TEMPLATE_TYPE_PARM>:
Don't walk TREE_TYPE.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-placeholder15.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 396e9118849c4b918eaf3edcfa60d36e2b973019)

6 weeks agoopenmp: Fix up ICE in lower_omp_regimplify_operands_p [PR121977]
Jakub Jelinek [Thu, 18 Sep 2025 14:41:32 +0000 (16:41 +0200)] 
openmp: Fix up ICE in lower_omp_regimplify_operands_p [PR121977]

The following testcase ICEs in functions called from
lower_omp_regimplify_operands_p, because maybe_lookup_decl returns
NULL for this (on the outer taskloop context) when regimplifying the
taskloop pre body.  If it isn't found in current context, we should
look in outer ones.

2025-09-18  Jakub Jelinek  <jakub@redhat.com>

PR c++/121977
* omp-low.cc (lower_omp_regimplify_operands_p): If maybe_lookup_decl
returns NULL, use maybe_lookup_decl_in_outer_ctx as fallback.

* g++.dg/gomp/pr121977.C: New test.

(cherry picked from commit b49f1dad54d3638384780c11ed17ab43f6d5d86f)

6 weeks agodocs: Adjust -Wimplicit-fallthrough= documentation for C23
Jakub Jelinek [Tue, 16 Sep 2025 17:25:58 +0000 (19:25 +0200)] 
docs: Adjust -Wimplicit-fallthrough= documentation for C23

I've noticed in -Wimplicit-fallthrough= documentation we talk about
[[fallthrough]]; for C++17 but don't mention that it is also standard
way to suppress the warning for C23.

2025-09-16  Jakub Jelinek  <jakub@redhat.com>

* doc/invoke.texi (Wimplicit-fallthrough=): Document that also C23
provides a standard way to suppress the warning with [[fallthrough]];.

(cherry picked from commit 5eb86c29d29fa25f8ad81d75730a993bb03fb558)

6 weeks agotestsuite: Only scan for known file extensions in lto.exp
Jakub Jelinek [Wed, 10 Sep 2025 10:39:11 +0000 (12:39 +0200)] 
testsuite: Only scan for known file extensions in lto.exp

This is something that has bothered me for a few years but I've only found
time for it now.
The glob used for finding *_1.* etc. counterparts to the *_0.* tests is too
broad, so if one has say next to *_1.c file also *_1.c~ or *_1.c.~1~
or *_1.c.orig or *_1.c.bak etc. files, lto.exp will report a warning and the
test will fail.
So, e.g. in rpm build if some backported commit in patch form adds some
gcc/testsuite/*.dg/lto/ test and one uses -b option to patch, if one doesn't
remove the backup files, the test will fail.

Looking through all the *.dg/lto/ directories, I only see c, C, ii, f, f90
and d extensions used right now for the *_1.* files (and higher), while for
the *_0.* files also m, mm and f03 extensions are used.

So, the following patch only searches for those (plus for Fortran uses the
extensions searched by the gfortran.dg/lto/ driver, i.e. \[fF\]{,90,95,03,08}
, not just f, f90 and f03).

Tested on x86_64-linux and verified I got exactly the same number of
grep '^Executing.on.host.*_[1-9]\.' testsuite/*/*.log
before/after this patch when doing make check RUNTESTFLAGS=lto.exp
except for 2 new ones which were previously failed because I had backup
files for 2 tests.

2025-09-10  Jakub Jelinek  <jakub@redhat.com>

* lib/lto.exp (lto-execute-1): Search for _1.* etc. files
only with a list of known extensions.

(cherry picked from commit 2bb8cd3609f5997b5a22925267b675808127311a)

6 weeks agobitint: Fix up lowering optimization of .*_OVERFLOW ifns [PR121828]
Jakub Jelinek [Wed, 10 Sep 2025 10:34:50 +0000 (12:34 +0200)] 
bitint: Fix up lowering optimization of .*_OVERFLOW ifns [PR121828]

THe lowering of .{ADD,SUB,MUL}_OVERFLOW ifns is optimized, so that we don't
in the common cases uselessly don't create a large _Complex _BitInt
temporary with the first (real) part being the result and second (imag) part
just being a huge 0 or 1, although we still do that if it can't be done.
The optimizable_arith_overflow function checks when that is possible, like
whether the ifn result is used at most twice, once in REALPART_EXPR and once
in IMAGPART_EXPR in the same bb, etc.  For IMAGPART_EXPR it then checks
if it has a single use which is a cast to some integral non-bitint type
(usually bool or int etc.).  The final check is whether that cast stmt
appears after the REALPART_EXPR (the usual case), in that case it is
optimizable, otherwise it is not (because the lowering for optimizable
ifns of this kind is done at the location of the REALPART_EXPR and it
tweaks the IMAGPART_EXPR cast location at that point, so otherwise it
would be set after use.

Now, we also have an optimization for the REALPART_EXPR lhs being used
in a single stmt - store in the same bb, in that case we don't have to
store the real part result in a temporary but it can go directly into
memory.
Except that nothing checks for the IMAGPART_EXPR cast being before or after
the store in this case, so the following testcase ICEs because we have
a use before a def stmt.

In bar (the function handled right already before this patch) we have
  _6 = .SUB_OVERFLOW (y_4(D), x_5(D));
  _1 = REALPART_EXPR <_6>;
  _2 = IMAGPART_EXPR <_6>;
  a = _1;
  _3 = (int) _2;
  baz (_3);
before the lowering, so we can just store the limbs of the .SUB_OVERFLOW
into the limbs of a variable and while doing that compute the value we
eventually store into _3 instead of the former a = _1; stmt.
In foo we have
  _5 = .SUB_OVERFLOW (y_3(D), x_4(D));
  _1 = REALPART_EXPR <_5>;
  _2 = IMAGPART_EXPR <_5>;
  t_6 = (int) _2;
  baz (t_6);
  a = _1;
and we can't do that because the lowering would be at the a = _1; stmt
and would try to set t_6 to the overflow flag at that point.  We don't
need to punt completely and mark _5 as _Complex _BitInt VAR_DECL though
in this case, all we need is not merge the a = _1; store with the
.SUB_OVERFLOW and REALPART_EXPR/IMAGPART_EXPR lowering.  So, add _1
to m_names and lower the first 3 stmts at the _1 = REALPART_EXPR <_5>;
location, optimizable_arith_overflow returned non-zero and so the
cast after IMAGPART_EXPR was after it and then a = _1; will copy from
the temporary VAR_DECL to memory.

2025-09-10  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/121828
* gimple-lower-bitint.cc (gimple_lower_bitint): For REALPART_EXPR
consumed by store in the same bb and with REALPART_EXPR from
optimizable_arith_overflow, don't add REALPART_EXPR lhs to
the m_names bitmap only if the cast from IMAGPART_EXPR doesn't
appear in between the REALPART_EXPR and the store.

* gcc.dg/bitint-126.c: New test.

(cherry picked from commit 29a8ce3b0bb117ed7f4b998462fe917f2a17f168)

6 weeks agoexpr: Handle RAW_DATA_CST in store_constructor [PR121831]
Jakub Jelinek [Wed, 10 Sep 2025 10:33:14 +0000 (12:33 +0200)] 
expr: Handle RAW_DATA_CST in store_constructor [PR121831]

I thought this wouldn't be necessary because RAW_DATA_CST can only appear
inside of (array) CONSTRUCTORs within DECL_INITIAL of TREE_STATIC vars,
so there shouldn't be a need to expand it.  Except that we have an
optimization when reading ARRAY_REF from such a CONSTRUCTOR which will
try to expand the constructor if it either can be stored by pieces
(I think that is just fine) or if it is mostly zeros (which is at least
75% of the initializer zeros).  Now the second case is I think in some
cases desirable (say 256MB initializer and just 20 elements out of that
non-zero, so clear everything and store 20 elements must be fastest and
short), but could be really bad as well (say 40GB initializer with
10GB non-zero in it, especially if it doesn't result in the original
variable being optimized away).  Maybe it would help if expand_constructor
and store_constructor* etc. had some optional argument with addresses into
the original VAR_DECL so that it could be copying larger amounts of data
like larger RAW_DATA_CSTs from there instead of pushing those into new
.rodata again.  And another problem is that we apparently expand the
initializes twice, expand_constructor in store_constructor can expand
the stores one and if expand_constructor returns non-NULL, we then
expand_expr the CONSTRUCTOR again. to the same location.

This patch doesn't address either of those issues, just adds RAW_DATA_CST
support to store_constructor for now.  For the can_store_by_pieces
cases it stores those by pieces using a new callback very similar to
string_cst_read_str, for the rest (unfortunately) forces it into a memory
and copies from there.

2025-09-10  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/121831
* expr.cc (raw_data_cst_read_str): New function.
(store_constructor) <case ARRAY_TYPE>: Handle RAW_DATA_CST.

* g++.dg/lto/pr121831_0.C: New test.
* g++.dg/lto/pr121831_1.C: New test.

(cherry picked from commit 225d13c01d4e231bfabfda1c1c9135e36f55946a)

6 weeks agolibstdc++: Fix up <ext/pointer.h> [PR121827]
Jakub Jelinek [Mon, 8 Sep 2025 09:49:58 +0000 (11:49 +0200)] 
libstdc++: Fix up <ext/pointer.h> [PR121827]

During the tests mentioned in
https://gcc.gnu.org/pipermail/gcc-patches/2025-August/692482.html
(but dunno why I haven't noticed it back in August but only when testing
https://gcc.gnu.org/pipermail/gcc-patches/2025-September/694527.html )
I've noticed two ext header problems.
One is that #include <ext/pointer.h> got broken with the
r13-3037-g18f176d0b25591e28 change and since then is no longer
self-contained, as it includes iosfwd only if _GLIBCXX_HOSTED is defined
but doesn't actually include bits/c++config.h to make sure it is defined,
then includes a bunch of headers which do include bits/c++config.h and
finally uses in #if _GLIBCXX_HOSTED guarded code what is declared in iosfwd.
The other problem is that ext/cast.h is also not a self-contained header,
but that one has
/** @file ext/cast.h
 *  This is an internal header file, included by other library headers.
 *  Do not attempt to use it directly. @headername{ext/pointer.h}
 */
comment, so I think we just shouldn't include it in extc++.h and let
ext/pointer.h include it.

2025-09-08  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/121827
* include/precompiled/extc++.h: Don't include ext/cast.h which is an
internal header.
* include/ext/pointer.h: Include bits/c++config.h before
#if _GLIBCXX_HOSTED.

(cherry picked from commit 592bafb26eb1fd50979f6cdf2176897c4a02c281)

6 weeks agotestsuite, powerpc, v2: Fix vsx-vectorize-* after alignment peeling [PR118567]
Jakub Jelinek [Fri, 5 Sep 2025 08:59:42 +0000 (10:59 +0200)] 
testsuite, powerpc, v2: Fix vsx-vectorize-* after alignment peeling [PR118567]

On Tue, Jul 01, 2025 at 02:50:40PM -0500, Segher Boessenkool wrote:
> No tests become good tests without effort.  And tests that are not good
> tests require constant maintenance!

Here are two patches, either just the first one or both can be used
and both were tested on powerpc64le-linux.

The second one adds further 8 tests, which are dg-do run which #include
the former tests, don't do any dump tests and just define the checking/main
for those.

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

PR testsuite/118567
* gcc.target/powerpc/vsx-vectorize-9.c: New test.
* gcc.target/powerpc/vsx-vectorize-10.c: New test.
* gcc.target/powerpc/vsx-vectorize-11.c: New test.
* gcc.target/powerpc/vsx-vectorize-12.c: New test.
* gcc.target/powerpc/vsx-vectorize-13.c: New test.
* gcc.target/powerpc/vsx-vectorize-14.c: New test.
* gcc.target/powerpc/vsx-vectorize-15.c: New test.
* gcc.target/powerpc/vsx-vectorize-16.c: New test.

(cherry picked from commit 8d8b6249d83609e56752ee51d2686b2f5fb062e6)

6 weeks agotestsuite, powerpc, v2: Fix vsx-vectorize-* after alignment peeling [PR118567]
Jakub Jelinek [Fri, 5 Sep 2025 08:54:53 +0000 (10:54 +0200)] 
testsuite, powerpc, v2: Fix vsx-vectorize-* after alignment peeling [PR118567]

On Tue, Jul 01, 2025 at 02:50:40PM -0500, Segher Boessenkool wrote:
> No tests become good tests without effort.  And tests that are not good
> tests require constant maintenance!

Here are two patches, either just the first one or both can be used
and both were tested on powerpc64le-linux.

The first one removes all the checking etc. stuff from the testcases,
as they are just dg-do compile, for the vectorize dump checks all we
care about are the vectorized loops they want to test.

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

PR testsuite/118567
* gcc.target/powerpc/vsx-vectorize-1.c: Remove includes, checking
part of main1 and main.
* gcc.target/powerpc/vsx-vectorize-2.c: Remove includes, replace
bar definition with declaration, remove main.
* gcc.target/powerpc/vsx-vectorize-3.c: Likewise.
* gcc.target/powerpc/vsx-vectorize-4.c: Likewise.
* gcc.target/powerpc/vsx-vectorize-5.c: Likewise.
* gcc.target/powerpc/vsx-vectorize-6.c: Likewise.
* gcc.target/powerpc/vsx-vectorize-7.c: Likewise.
* gcc.target/powerpc/vsx-vectorize-8.c: Likewise.

(cherry picked from commit 193b28649933685f4dd3824c01aee4f843cc66b5)

6 weeks agoomp-expand: Initialize fd->loop.n2 if needed for the zero iter case [PR121453]
Jakub Jelinek [Mon, 25 Aug 2025 22:28:10 +0000 (00:28 +0200)] 
omp-expand: Initialize fd->loop.n2 if needed for the zero iter case [PR121453]

When expand_omp_for_init_counts is called from expand_omp_for_generic,
zero_iter1_bb is NULL and the code always creates a new bb in which it
clears fd->loop.n2 var (if it is a var), because it can dominate code
with lastprivate guards that use the var.
When called from other places, zero_iter1_bb is non-NULL and so we don't
insert the clearing (and can't, because the same bb is used also for the
non-zero iterations exit and in that case we need to preserve the iteration
count).  Clearing is also not necessary when e.g. outermost collapsed
loop has constant non-zero number of iterations, in that case we initialize the
var to something already earlier.  The following patch makes sure to clear
it if it hasn't been initialized yet before the first check for zero iterations.

2025-08-26  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/121453
* omp-expand.cc (expand_omp_for_init_counts): Clear fd->loop.n2
before first zero count check if zero_iter1_bb is non-NULL upon
entry and fd->loop.n2 has not been written yet.

* gcc.dg/gomp/pr121453.c: New test.

(cherry picked from commit 948f20cc520e50968f8759b173096358dcbba3de)

6 weeks agoc++: Fix up build_cplus_array_type [PR121524]
Jakub Jelinek [Thu, 14 Aug 2025 20:30:45 +0000 (22:30 +0200)] 
c++: Fix up build_cplus_array_type [PR121524]

The following testcase is miscompiled since my r15-3046 change
to properly apply std attributes after closing ] for arrays to the
array type.
Array type is not a class type, so when cplus_decl_attribute is
called on the ARRAY_TYPE, it doesn't do ATTR_FLAG_TYPE_IN_PLACE.
Though, for alignas/gnu::aligned/deprecated/gnu::unavailable/gnu::unused
attributes the handlers of those attributes for non-ATTR_FLAG_TYPE_IN_PLACE
on types call build_variant_type_copy and modify some flags on the new
variant type.  They also usually don't clear *no_add_attrs, so the caller
then checks if the attributes are present on the new type and if not, calls
build_type_attribute_variant.
On the following testcase, it results in the B::foo type to be properly
32 byte aligned.
The problem happens later when we build_cplus_array_type for C::a.
elt_type is T (typedef, or using works likewise), we get as m
main variant type with unsigned int element type but because elt_type
is different, build_cplus_array_type searches the TYPE_NEXT_VARIANT chain
to find if there isn't already a useful ARRAY_TYPE to reuse.
It checks for NULL TYPE_NAME, NULL TYPE_ATTRIBUTES and the right TREE_TYPE.
Unfortunately this is not good enough, build_variant_type_copy above created
a variant type on which it modified TYPE_USER_ALIGN and TYPE_ALIGN, but
TYPE_ATTRIBUTES is still NULL, only the build_type_attribute_variant call
later adds attributes.
The problem is that the intermediate type is found in the TYPE_NEXT_VARIANT
chain and reused.

The following patch adds conditions to prevent problems with the affected
attributes (except gnu::unused, I think whether TREE_USED is set or not
shouldn't prevent sharing).  In particular, if TYPE_USER_ALIGN is not
set on the variant, it wasn't user realigned, if it is set, it verifies
it has it set because the elt_type has been user aligned and TYPE_ALIGN
is the expected one.  For deprecated it punts on the flag being set and
for gnu::unavailable as well.

2025-08-14  Jakub Jelinek  <jakub@redhat.com>

PR c++/121524
* tree.cc (build_cplus_array_type): Don't reuse variant type
if it has TREE_DEPRECATED or TREE_UNAVAILABLE flags set or,
unless elt_type has TYPE_USER_ALIGN set and TYPE_ALIGN is
TYPE_ALIGN of elt_type, TYPE_USER_ALIGN is not set.

* g++.dg/cpp0x/gen-attrs-89.C: New test.

(cherry picked from commit b125eee2d8526538476834773fb8216035d08598)

6 weeks agotree-optimization/122016 - PRE insertion breaks abnormal coalescing
Richard Biener [Mon, 22 Sep 2025 08:14:31 +0000 (10:14 +0200)] 
tree-optimization/122016 - PRE insertion breaks abnormal coalescing

When PRE asks VN to simplify a NARY but not insert, that bypasses
the abnormal guard in maybe_push_res_to_seq and we blindly accept
new uses of abnormals.  The following fixes this.

PR tree-optimization/122016
* tree-ssa-sccvn.cc (vn_nary_simplify): Do not use the
simplified expression when it references abnormals.

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

(cherry picked from commit 52b53cfb5392257536fce8dd22ea60412ceaee7d)

6 weeks agoDeal with prior EH/abormal cleanup when fixing up noreturn calls
Richard Biener [Wed, 10 Sep 2025 15:14:07 +0000 (17:14 +0200)] 
Deal with prior EH/abormal cleanup when fixing up noreturn calls

When a dead EH or abnormal edge makes a call queued for noreturn fixup
unreachable, just skip processing it.

PR tree-optimization/121870
* tree-ssa-propagate.cc
(substitute_and_fold_engine::substitute_and_fold): Skip
removed stmts from noreturn fixup.

* g++.dg/torture/pr121870.C: New testcase.

(cherry picked from commit 5c4f1313e753aeb6920a48c62c7c99ad36e1adae)

6 weeks agotree-optimization/121844 - IVOPTs and asm goto in latch
Richard Biener [Mon, 8 Sep 2025 12:32:38 +0000 (14:32 +0200)] 
tree-optimization/121844 - IVOPTs and asm goto in latch

When there's an asm goto in the latch of a loop we may not use
IP_END IVs since instantiating those would (need to) split the
latch edge which in turn invalidates IP_NORMAL position handling.
This is a revision of the PR107997 fix.

PR tree-optimization/107997
PR tree-optimization/121844
* tree-ssa-loop-ivopts.cc (allow_ip_end_pos_p): Do not allow
IP_END for latches ending with a control stmt.
(create_new_iv): Do not split the latch edge, instead assert
that's not necessary.

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

(cherry picked from commit 00cd34b1046076a3272f8e8e85c97dc8f4d2ea44)