]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
21 months agors6000: Skip empty inline asm in rs6000_update_ipa_fn_target_info [PR111366]
Kewen Lin [Mon, 16 Oct 2023 02:08:26 +0000 (21:08 -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)

21 months agoDaily bump.
GCC Administrator [Mon, 16 Oct 2023 00:19:30 +0000 (00:19 +0000)] 
Daily bump.

21 months agoDaily bump.
GCC Administrator [Sun, 15 Oct 2023 00:19:35 +0000 (00:19 +0000)] 
Daily bump.

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

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

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

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

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

22 months agoDaily bump.
GCC Administrator [Mon, 9 Oct 2023 00:19:59 +0000 (00:19 +0000)] 
Daily bump.

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

22 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)

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

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

22 months agoDaily bump.
GCC Administrator [Thu, 5 Oct 2023 00:20:50 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Wed, 4 Oct 2023 00:19:57 +0000 (00:19 +0000)] 
Daily bump.

22 months agolibstdc++: Fix linker errors for directory iterator comparisons
Jonathan Wakely [Tue, 3 Oct 2023 16:41:14 +0000 (17:41 +0100)] 
libstdc++: Fix linker errors for directory iterator comparisons

These new comparison operators for std::default_sentinel_t require some
new symbol exports, which were added with r13-5662-gdb8d6fc572ec31 for
trunk, but that isn't suitable for the gcc-12 branch.

Define them as specified in the standard instead, which doesn't require
any new symbols.

libstdc++-v3/ChangeLog:

* include/bits/fs_dir.h (directory_iterator::operator==):
Define without using a non-exported shared_ptr symbol.
(recursive_directory_iterator::operator==): Likewise.

22 months agolibstdc++: Use dg-require-filesystem-ts in link test
Jonathan Wakely [Thu, 31 Aug 2023 17:35:12 +0000 (18:35 +0100)] 
libstdc++: Use dg-require-filesystem-ts in link test

This test expects to be able to link, which fails if there are undefined
references to chdir, mkdir etc. in fs_ops.o in the libstdc++.a archive.

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/path/108636.cc: Add dg-require for
filesystem support.

(cherry picked from commit c07d82c12f2f17427a89188abad69af195590309)

22 months agolibstdc++: Make std::filesystem::copy_file work for procfs [PR108178]
Jonathan Wakely [Tue, 21 Mar 2023 12:29:08 +0000 (12:29 +0000)] 
libstdc++: Make std::filesystem::copy_file work for procfs [PR108178]

The size reported by stat is always zero for some special files such as
those under /proc, which means the current copy_file implementation
thinks there is nothing to copy. Instead of trusting the stat value, try
to read a character from a streambuf and check for EOF.

For the backport, we also need to avoid trying to use sendfile when stat
reports a zero size, so that we use streambufs to copy the file.

libstdc++-v3/ChangeLog:

PR libstdc++/108178
* src/filesystem/ops-common.h (do_copy_file): Check for empty
files by trying to read a character.
* testsuite/27_io/filesystem/operations/copy_file_108178.cc:
New test.

(cherry picked from commit 07a0e108247f23fcb919c61595adae143f1ea02a)

22 months agolibstdc++: Use close-on-exec for file descriptors in filesystem::copy_file
Jonathan Wakely [Mon, 5 Jun 2023 16:45:37 +0000 (17:45 +0100)] 
libstdc++: Use close-on-exec for file descriptors in filesystem::copy_file

libstdc++-v3/ChangeLog:

* src/filesystem/ops-common.h (do_copy_file) [O_CLOEXEC]: Set
close-on-exec flag on file descriptors.

(cherry picked from commit 7e8e071c4b64f1b6ea5ddf528724fc793a0f0e36)

22 months agolibstdc++: Fix formatting in std::filesystem helper function
Jonathan Wakely [Mon, 20 Mar 2023 13:40:59 +0000 (13:40 +0000)] 
libstdc++: Fix formatting in std::filesystem helper function

libstdc++-v3/ChangeLog:

* src/filesystem/ops-common.h (get_temp_directory_from_env): Fix
formatting.

(cherry picked from commit ccfca55536f87a1332f844efcc66b8383030d149)

22 months agolibstdc++: Use ENOSYS for unsupported filesystem ops on AVR
Jonathan Wakely [Thu, 2 Feb 2023 16:00:21 +0000 (16:00 +0000)] 
libstdc++: Use ENOSYS for unsupported filesystem ops on AVR

Because avr-libc <errno.h> defines most error numbers with duplicate
values it's not sufficient to check #ifdef ENOTSUP when deciding which
std::errc constant to use for the filesystem library's __unsupported()
helper. Add a special case for AVR to always use the ENOSYS value.

libstdc++-v3/ChangeLog:

* src/filesystem/ops-common.h [AVR] (__unsupported): Always use
errc::function_not_supported instead of errc::not_supported.

(cherry picked from commit 5c43f06c228d169c370e99fa009154344fa305b8)

22 months agoDaily bump.
GCC Administrator [Tue, 3 Oct 2023 00:19:15 +0000 (00:19 +0000)] 
Daily bump.

22 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)

22 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)

22 months agoDaily bump.
GCC Administrator [Mon, 2 Oct 2023 00:19:31 +0000 (00:19 +0000)] 
Daily bump.

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

22 months agoDaily bump.
GCC Administrator [Sat, 30 Sep 2023 00:19:50 +0000 (00:19 +0000)] 
Daily bump.

22 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)

22 months agoDaily bump.
GCC Administrator [Fri, 29 Sep 2023 00:19:48 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Thu, 28 Sep 2023 09:52:21 +0000 (09:52 +0000)] 
Daily bump.

22 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/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)

22 months agolibstdc++: Prevent unwanted ADL in std::to_array [PR111512]
Jonathan Wakely [Thu, 21 Sep 2023 08:14:57 +0000 (09:14 +0100)] 
libstdc++: Prevent unwanted ADL in std::to_array [PR111512]

Qualify the calls to the __to_array helper to prevent ADL, so we don't
try to complete associated classes.

libstdc++-v3/ChangeLog:

PR libstdc++/111511
PR c++/111512
* include/std/array (to_array): Qualify calls to __to_array.
* testsuite/23_containers/array/creation/111512.cc: New test.

(cherry picked from commit 77cf3773021b0a20d89623e09d620747a05588ec)

22 months agoAdd missing return in gori_compute::logical_combine
Eric Botcazou [Mon, 25 Sep 2023 18:48:53 +0000 (20:48 +0200)] 
Add missing return in gori_compute::logical_combine

The varying case currently falls through to the 1/true case.

gcc/
* gimple-range-gori.cc (gori_compute::logical_combine): Add missing
return statement in the varying case.

gcc/testsuite/
* gnat.dg/opt102.adb:New test.
* gnat.dg/opt102_pkg.adb, gnat.dg/opt102_pkg.ads: New helper.

22 months agoDaily bump.
GCC Administrator [Tue, 26 Sep 2023 00:20:24 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Mon, 25 Sep 2023 00:19:48 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 24 Sep 2023 00:19:45 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sat, 23 Sep 2023 00:20:45 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Fri, 22 Sep 2023 00:19:36 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Thu, 21 Sep 2023 00:20:24 +0000 (00:20 +0000)] 
Daily bump.

22 months agoaarch64: Fix loose ldpstp check [PR111411]
Richard Sandiford [Wed, 20 Sep 2023 10:13:20 +0000 (11:13 +0100)] 
aarch64: Fix loose ldpstp check [PR111411]

aarch64_operands_ok_for_ldpstp contained the code:

  /* One of the memory accesses must be a mempair operand.
     If it is not the first one, they need to be swapped by the
     peephole.  */
  if (!aarch64_mem_pair_operand (mem_1, GET_MODE (mem_1))
       && !aarch64_mem_pair_operand (mem_2, GET_MODE (mem_2)))
    return false;

But the requirement isn't just that one of the accesses must be a
valid mempair operand.  It's that the lower access must be, since
that's the access that will be used for the instruction operand.

gcc/
PR target/111411
* config/aarch64/aarch64.cc (aarch64_operands_ok_for_ldpstp): Require
the lower memory access to a mem-pair operand.

gcc/testsuite/
PR target/111411
* gcc.dg/rtl/aarch64/pr111411.c: New test.

(cherry picked from commit 2d38f45bcca62ca0c7afef4b579f82c5c2a01610)

22 months agoaarch64: Fix return register handling in untyped_call
Richard Sandiford [Wed, 20 Sep 2023 10:13:19 +0000 (11:13 +0100)] 
aarch64: Fix return register handling in untyped_call

While working on another patch, I hit a problem with the aarch64
expansion of untyped_call.  The expander emits the usual:

  (set (mem ...) (reg resN))

instructions to store the result registers to memory, but it didn't
say in RTL where those resN results came from.  This eventually led
to a failure of gcc.dg/torture/stackalign/builtin-return-2.c,
via regrename.

This patch turns the untyped call from a plain call to a call_value,
to represent that the call returns (or might return) a useful value.
The patch also uses a PARALLEL return rtx to represent all the possible
return registers.

gcc/
* config/aarch64/aarch64.md (untyped_call): Emit a call_value
rather than a call.  List each possible destination register
in the call pattern.

(cherry picked from commit 629efe27744d13c3b83bbe8338b84c37c83dbe4f)

22 months agoDaily bump.
GCC Administrator [Wed, 20 Sep 2023 00:20:07 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Tue, 19 Sep 2023 00:19:43 +0000 (00:19 +0000)] 
Daily bump.

22 months agolibstdc++: Update C++20 status docs
Jonathan Wakely [Mon, 18 Sep 2023 14:30:05 +0000 (15:30 +0100)] 
libstdc++: Update C++20 status docs

libstdc++-v3/ChangeLog:

* doc/xml/manual/configure.xml: Use conventional option name.
* doc/xml/manual/status_cxx2020.xml: Update.
* doc/html/*: Regenerate.

(cherry picked from commit c8e9a75085f9725c5b5f32a27867c106fed3b5fb)

22 months agoDaily bump.
GCC Administrator [Mon, 18 Sep 2023 00:19:26 +0000 (00:19 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sun, 17 Sep 2023 00:20:43 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Sat, 16 Sep 2023 00:20:21 +0000 (00:20 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Fri, 15 Sep 2023 00:20:19 +0000 (00:20 +0000)] 
Daily bump.

22 months agolibstdc++: Add workaround for std::make_integer_sequence bug [PR111357]
Jonathan Wakely [Thu, 14 Sep 2023 08:18:34 +0000 (09:18 +0100)] 
libstdc++: Add workaround for std::make_integer_sequence bug [PR111357]

The compiler bug has been fixed on trunk, but we need this workaround on
the branches.

libstdc++-v3/ChangeLog:

PR c++/111357
* include/bits/utility.h (make_integer_sequence): Add cast.
* testsuite/20_util/integer_sequence/pr111357.cc: New test.

(cherry picked from commit 7b0abd4a8ee9d2057febe443de67009dcdfe7574)

22 months agoDaily bump.
GCC Administrator [Thu, 14 Sep 2023 00:24:04 +0000 (00:24 +0000)] 
Daily bump.

22 months agoDaily bump.
GCC Administrator [Wed, 13 Sep 2023 00:24:38 +0000 (00:24 +0000)] 
Daily bump.

22 months agoi386: Handle CONST_WIDE_INT in output_pic_addr_const [PR111340]
Uros Bizjak [Mon, 11 Sep 2023 18:56:42 +0000 (20:56 +0200)] 
i386: Handle CONST_WIDE_INT in output_pic_addr_const [PR111340]

PR target/111340

gcc/ChangeLog:

* config/i386/i386.cc (output_pic_addr_const): Handle CONST_WIDE_INT.
Call output_addr_const for CASE_CONST_SCALAR_INT.

gcc/testsuite/ChangeLog:

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

22 months agoaarch64: Make stack smash canary protect saved registers
Richard Sandiford [Tue, 12 Sep 2023 15:08:57 +0000 (16:08 +0100)] 
aarch64: Make stack smash canary protect saved registers

AArch64 normally puts the saved registers near the bottom of the frame,
immediately above any dynamic allocations.  But this means that a
stack-smash attack on those dynamic allocations could overwrite the
saved registers without needing to reach as far as the stack smash
canary.

The same thing could also happen for variable-sized arguments that are
passed by value, since those are allocated before a call and popped on
return.

This patch avoids that by putting the locals (and thus the canary) below
the saved registers when stack smash protection is active.

The patch fixes CVE-2023-4039.

gcc/
* config/aarch64/aarch64.cc (aarch64_save_regs_above_locals_p):
New function.
(aarch64_layout_frame): Use it to decide whether locals should
go above or below the saved registers.
(aarch64_expand_prologue): Update stack layout comment.
Emit a stack tie after the final adjustment.

gcc/testsuite/
* gcc.target/aarch64/stack-protector-8.c: New test.
* gcc.target/aarch64/stack-protector-9.c: Likewise.

22 months agoaarch64: Remove below_hard_fp_saved_regs_size
Richard Sandiford [Tue, 12 Sep 2023 15:08:56 +0000 (16:08 +0100)] 
aarch64: Remove below_hard_fp_saved_regs_size

After previous patches, it's no longer necessary to store
saved_regs_size and below_hard_fp_saved_regs_size in the frame info.
All measurements instead use the top or bottom of the frame as
reference points.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::saved_regs_size)
(aarch64_frame::below_hard_fp_saved_regs_size): Delete.
* config/aarch64/aarch64.cc (aarch64_layout_frame): Update accordingly.

22 months agoaarch64: Explicitly record probe registers in frame info
Richard Sandiford [Tue, 12 Sep 2023 15:08:56 +0000 (16:08 +0100)] 
aarch64: Explicitly record probe registers in frame info

The stack frame is currently divided into three areas:

A: the area above the hard frame pointer
B: the SVE saves below the hard frame pointer
C: the outgoing arguments

If the stack frame is allocated in one chunk, the allocation needs a
probe if the frame size is >= guard_size - 1KiB.  In addition, if the
function is not a leaf function, it must probe an address no more than
1KiB above the outgoing SP.  We ensured the second condition by

(1) using single-chunk allocations for non-leaf functions only if
    the link register save slot is within 512 bytes of the bottom
    of the frame; and

(2) using the link register save as a probe (meaning, for instance,
    that it can't be individually shrink wrapped)

If instead the stack is allocated in multiple chunks, then:

* an allocation involving only the outgoing arguments (C above) requires
  a probe if the allocation size is > 1KiB

* any other allocation requires a probe if the allocation size
  is >= guard_size - 1KiB

* second and subsequent allocations require the previous allocation
  to probe at the bottom of the allocated area, regardless of the size
  of that previous allocation

The final point means that, unlike for single allocations,
it can be necessary to have both a non-SVE register probe and
an SVE register probe.  For example:

* allocate A, probe using a non-SVE register save
* allocate B, probe using an SVE register save
* allocate C

The non-SVE register used in this case was again the link register.
It was previously used even if the link register save slot was some
bytes above the bottom of the non-SVE register saves, but an earlier
patch avoided that by putting the link register save slot first.

As a belt-and-braces fix, this patch explicitly records which
probe registers we're using and allows the non-SVE probe to be
whichever register comes first (as for SVE).

The patch also avoids unnecessary probes in sve/pcs/stack_clash_3.c.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::sve_save_and_probe)
(aarch64_frame::hard_fp_save_and_probe): New fields.
* config/aarch64/aarch64.cc (aarch64_layout_frame): Initialize them.
Rather than asserting that a leaf function saves LR, instead assert
that a leaf function saves something.
(aarch64_get_separate_components): Prevent the chosen probe
registers from being individually shrink-wrapped.
(aarch64_allocate_and_probe_stack_space): Remove workaround for
probe registers that aren't at the bottom of the previous allocation.

gcc/testsuite/
* gcc.target/aarch64/sve/pcs/stack_clash_3.c: Avoid redundant probes.

22 months agoaarch64: Simplify probe of final frame allocation
Richard Sandiford [Tue, 12 Sep 2023 15:08:55 +0000 (16:08 +0100)] 
aarch64: Simplify probe of final frame allocation

Previous patches ensured that the final frame allocation only needs
a probe when the size is strictly greater than 1KiB.  It's therefore
safe to use the normal 1024 probe offset in all cases.

The main motivation for doing this is to simplify the code and
remove the number of special cases.

gcc/
* config/aarch64/aarch64.cc (aarch64_allocate_and_probe_stack_space):
Always probe the residual allocation at offset 1024, asserting
that that is in range.

gcc/testsuite/
* gcc.target/aarch64/stack-check-prologue-17.c: Expect the probe
to be at offset 1024 rather than offset 0.
* gcc.target/aarch64/stack-check-prologue-18.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-19.c: Likewise.

22 months agoaarch64: Put LR save probe in first 16 bytes
Richard Sandiford [Tue, 12 Sep 2023 15:08:55 +0000 (16:08 +0100)] 
aarch64: Put LR save probe in first 16 bytes

-fstack-clash-protection uses the save of LR as a probe for the next
allocation.  The next allocation could be:

* another part of the static frame, e.g. when allocating SVE save slots
  or outgoing arguments

* an alloca in the same function

* an allocation made by a callee function

However, when -fomit-frame-pointer is used, the LR save slot is placed
above the other GPR save slots.  It could therefore be up to 80 bytes
above the base of the GPR save area (which is also the hard fp address).

aarch64_allocate_and_probe_stack_space took this into account when
deciding how much subsequent space could be allocated without needing
a probe.  However, it interacted badly with:

      /* If doing a small final adjustment, we always probe at offset 0.
 This is done to avoid issues when LR is not at position 0 or when
 the final adjustment is smaller than the probing offset.  */
      else if (final_adjustment_p && rounded_size == 0)
residual_probe_offset = 0;

which forces any allocation that is smaller than the guard page size
to be probed at offset 0 rather than the usual offset 1024.  It was
therefore possible to construct cases in which we had:

* a probe using LR at SP + 80 bytes (or some other value >= 16)
* an allocation of the guard page size - 16 bytes
* a probe at SP + 0

which allocates guard page size + 64 consecutive unprobed bytes.

This patch requires the LR probe to be in the first 16 bytes of the
save area when stack clash protection is active.  Doing it
unconditionally would cause code-quality regressions.

Putting LR before other registers prevents push/pop allocation
when shadow call stacks are enabled, since LR is restored
separately from the other callee-saved registers.

The new comment doesn't say that the probe register is required
to be LR, since a later patch removes that restriction.

gcc/
* config/aarch64/aarch64.cc (aarch64_layout_frame): Ensure that
the LR save slot is in the first 16 bytes of the register save area.
Only form STP/LDP push/pop candidates if both registers are valid.
(aarch64_allocate_and_probe_stack_space): Remove workaround for
when LR was not in the first 16 bytes.

gcc/testsuite/
* gcc.target/aarch64/stack-check-prologue-18.c: New test.
* gcc.target/aarch64/stack-check-prologue-19.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-20.c: Likewise.

22 months agoaarch64: Tweak stack clash boundary condition
Richard Sandiford [Tue, 12 Sep 2023 15:08:54 +0000 (16:08 +0100)] 
aarch64: Tweak stack clash boundary condition

The AArch64 ABI says that, when stack clash protection is used,
there can be a maximum of 1KiB of unprobed space at sp on entry
to a function.  Therefore, we need to probe when allocating
>= guard_size - 1KiB of data (>= rather than >).  This is what
GCC does.

If an allocation is exactly guard_size bytes, it is enough to allocate
those bytes and probe once at offset 1024.  It isn't possible to use a
single probe at any other offset: higher would conmplicate later code,
by leaving more unprobed space than usual, while lower would risk
leaving an entire page unprobed.  For simplicity, the code probes all
allocations at offset 1024.

Some register saves also act as probes.  If we need to allocate
more space below the last such register save probe, we need to
probe the allocation if it is > 1KiB.  Again, this allocation is
then sometimes (but not always) probed at offset 1024.  This sort of
allocation is currently only used for outgoing arguments, which are
rarely this big.

However, the code also probed if this final outgoing-arguments
allocation was == 1KiB, rather than just > 1KiB.  This isn't
necessary, since the register save then probes at offset 1024
as required.  Continuing to probe allocations of exactly 1KiB
would complicate later patches.

gcc/
* config/aarch64/aarch64.cc (aarch64_allocate_and_probe_stack_space):
Don't probe final allocations that are exactly 1KiB in size (after
unprobed space above the final allocation has been deducted).

gcc/testsuite/
* gcc.target/aarch64/stack-check-prologue-17.c: New test.

22 months agoaarch64: Minor initial adjustment tweak
Richard Sandiford [Tue, 12 Sep 2023 15:08:54 +0000 (16:08 +0100)] 
aarch64: Minor initial adjustment tweak

This patch just changes a calculation of initial_adjust
to one that makes it slightly more obvious that the total
adjustment is frame.frame_size.

gcc/
* config/aarch64/aarch64.cc (aarch64_layout_frame): Tweak
calculation of initial_adjust for frames in which all saves
are SVE saves.

22 months agoaarch64: Simplify top of frame allocation
Richard Sandiford [Tue, 12 Sep 2023 15:08:53 +0000 (16:08 +0100)] 
aarch64: Simplify top of frame allocation

After previous patches, it no longer really makes sense to allocate
the top of the frame in terms of varargs_and_saved_regs_size and
saved_regs_and_above.

gcc/
* config/aarch64/aarch64.cc (aarch64_layout_frame): Simplify
the allocation of the top of the frame.

22 months agoaarch64: Measure reg_offset from the bottom of the frame
Richard Sandiford [Tue, 12 Sep 2023 15:08:53 +0000 (16:08 +0100)] 
aarch64: Measure reg_offset from the bottom of the frame

reg_offset was measured from the bottom of the saved register area.
This made perfect sense with the original layout, since the bottom
of the saved register area was also the hard frame pointer address.
It became slightly less obvious with SVE, since we save SVE
registers below the hard frame pointer, but it still made sense.

However, if we want to allow different frame layouts, it's more
convenient and obvious to measure reg_offset from the bottom of
the frame.  After previous patches, it's also a slight simplification
in its own right.

gcc/
* config/aarch64/aarch64.h (aarch64_frame): Add comment above
reg_offset.
* config/aarch64/aarch64.cc (aarch64_layout_frame): Walk offsets
from the bottom of the frame, rather than the bottom of the saved
register area.  Measure reg_offset from the bottom of the frame
rather than the bottom of the saved register area.
(aarch64_save_callee_saves): Update accordingly.
(aarch64_restore_callee_saves): Likewise.
(aarch64_get_separate_components): Likewise.
(aarch64_process_components): Likewise.

22 months agoaarch64: Tweak frame_size comment
Richard Sandiford [Tue, 12 Sep 2023 15:08:52 +0000 (16:08 +0100)] 
aarch64: Tweak frame_size comment

This patch fixes another case in which a value was described with
an “upside-down” view.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::frame_size): Tweak comment.

22 months agoaarch64: Rename hard_fp_offset to bytes_above_hard_fp
Richard Sandiford [Tue, 12 Sep 2023 15:08:52 +0000 (16:08 +0100)] 
aarch64: Rename hard_fp_offset to bytes_above_hard_fp

Similarly to the previous locals_offset patch, hard_fp_offset
was described as:

  /* Offset from the base of the frame (incomming SP) to the
     hard_frame_pointer.  This value is always a multiple of
     STACK_BOUNDARY.  */
  poly_int64 hard_fp_offset;

which again took an “upside-down” view: higher offsets meant lower
addresses.  This patch renames the field to bytes_above_hard_fp instead.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::hard_fp_offset): Rename
to...
(aarch64_frame::bytes_above_hard_fp): ...this.
* config/aarch64/aarch64.cc (aarch64_layout_frame)
(aarch64_expand_prologue): Update accordingly.
(aarch64_initial_elimination_offset): Likewise.

22 months agoaarch64: Rename locals_offset to bytes_above_locals
Richard Sandiford [Tue, 12 Sep 2023 15:08:51 +0000 (16:08 +0100)] 
aarch64: Rename locals_offset to bytes_above_locals

locals_offset was described as:

  /* Offset from the base of the frame (incomming SP) to the
     top of the locals area.  This value is always a multiple of
     STACK_BOUNDARY.  */

This is implicitly an “upside down” view of the frame: the incoming
SP is at offset 0, and anything N bytes below the incoming SP is at
offset N (rather than -N).

However, reg_offset instead uses a “right way up” view; that is,
it views offsets in address terms.  Something above X is at a
positive offset from X and something below X is at a negative
offset from X.

Also, even on FRAME_GROWS_DOWNWARD targets like AArch64,
target-independent code views offsets in address terms too:
locals are allocated at negative offsets to virtual_stack_vars.

It seems confusing to have *_offset fields of the same structure
using different polarities like this.  This patch tries to avoid
that by renaming locals_offset to bytes_above_locals.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::locals_offset): Rename to...
(aarch64_frame::bytes_above_locals): ...this.
* config/aarch64/aarch64.cc (aarch64_layout_frame)
(aarch64_initial_elimination_offset): Update accordingly.

22 months agoaarch64: Only calculate chain_offset if there is a chain
Richard Sandiford [Tue, 12 Sep 2023 15:08:51 +0000 (16:08 +0100)] 
aarch64: Only calculate chain_offset if there is a chain

After previous patches, it is no longer necessary to calculate
a chain_offset in cases where there is no chain record.

gcc/
* config/aarch64/aarch64.cc (aarch64_expand_prologue): Move the
calculation of chain_offset into the emit_frame_chain block.

22 months agoaarch64: Tweak aarch64_save/restore_callee_saves
Richard Sandiford [Tue, 12 Sep 2023 15:08:50 +0000 (16:08 +0100)] 
aarch64: Tweak aarch64_save/restore_callee_saves

aarch64_save_callee_saves and aarch64_restore_callee_saves took
a parameter called start_offset that gives the offset of the
bottom of the saved register area from the current stack pointer.
However, it's more convenient for later patches if we use the
bottom of the entire frame as the reference point, rather than
the bottom of the saved registers.

Doing that removes the need for the callee_offset field.
Other than that, this is not a win on its own.  It only really
makes sense in combination with the follow-on patches.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::callee_offset): Delete.
* config/aarch64/aarch64.cc (aarch64_layout_frame): Remove
callee_offset handling.
(aarch64_save_callee_saves): Replace the start_offset parameter
with a bytes_below_sp parameter.
(aarch64_restore_callee_saves): Likewise.
(aarch64_expand_prologue): Update accordingly.
(aarch64_expand_epilogue): Likewise.

22 months agoaarch64: Add bytes_below_hard_fp to frame info
Richard Sandiford [Tue, 12 Sep 2023 15:08:50 +0000 (16:08 +0100)] 
aarch64: Add bytes_below_hard_fp to frame info

Following on from the previous bytes_below_saved_regs patch, this one
records the number of bytes that are below the hard frame pointer.
This eventually replaces below_hard_fp_saved_regs_size.

If a frame pointer is not needed, the epilogue adds final_adjust
to the stack pointer before restoring registers:

     aarch64_add_sp (tmp1_rtx, tmp0_rtx, final_adjust, true);

Therefore, if the epilogue needs to restore the stack pointer from
the hard frame pointer, the directly corresponding offset is:

     -bytes_below_hard_fp + final_adjust

i.e. go from the hard frame pointer to the bottom of the frame,
then add the same amount as if we were using the stack pointer
from the outset.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::bytes_below_hard_fp): New
field.
* config/aarch64/aarch64.cc (aarch64_layout_frame): Initialize it.
(aarch64_expand_epilogue): Use it instead of
below_hard_fp_saved_regs_size.

22 months agoaarch64: Add bytes_below_saved_regs to frame info
Richard Sandiford [Tue, 12 Sep 2023 15:08:49 +0000 (16:08 +0100)] 
aarch64: Add bytes_below_saved_regs to frame info

The frame layout code currently hard-codes the assumption that
the number of bytes below the saved registers is equal to the
size of the outgoing arguments.  This patch abstracts that
value into a new field of aarch64_frame.

gcc/
* config/aarch64/aarch64.h (aarch64_frame::bytes_below_saved_regs): New
field.
* config/aarch64/aarch64.cc (aarch64_layout_frame): Initialize it,
and use it instead of crtl->outgoing_args_size.
(aarch64_get_separate_components): Use bytes_below_saved_regs instead
of outgoing_args_size.
(aarch64_process_components): Likewise.

22 months agoaarch64: Explicitly handle frames with no saved registers
Richard Sandiford [Tue, 12 Sep 2023 15:08:49 +0000 (16:08 +0100)] 
aarch64: Explicitly handle frames with no saved registers

If a frame has no saved registers, it can be allocated in one go.
There is no need to treat the areas below and above the saved
registers as separate.

And if we allocate the frame in one go, it should be allocated
as the initial_adjust rather than the final_adjust.  This allows the
frame size to grow to guard_size - guard_used_by_caller before a stack
probe is needed.  (A frame with no register saves is necessarily a
leaf frame.)

This is a no-op as thing stand, since a leaf function will have
no outgoing arguments, and so all the frame will be above where
the saved registers normally go.

gcc/
* config/aarch64/aarch64.cc (aarch64_layout_frame): Explicitly
allocate the frame in one go if there are no saved registers.

22 months agoaarch64: Avoid a use of callee_offset
Richard Sandiford [Tue, 12 Sep 2023 15:08:49 +0000 (16:08 +0100)] 
aarch64: Avoid a use of callee_offset

When we emit the frame chain, i.e. when we reach Here in this statement
of aarch64_expand_prologue:

  if (emit_frame_chain)
    {
      // Here
      ...
    }

the stack is in one of two states:

- We've allocated up to the frame chain, but no more.

- We've allocated the whole frame, and the frame chain is within easy
  reach of the new SP.

The offset of the frame chain from the current SP is available
in aarch64_frame as callee_offset.  It is also available as the
chain_offset local variable, where the latter is calculated from other
data.  (However, chain_offset is not always equal to callee_offset when
!emit_frame_chain, so chain_offset isn't redundant.)

In c600df9a4060da3c6121ff4d0b93f179eafd69d1 I switched to using
chain_offset for the initialisation of the hard frame pointer:

       aarch64_add_offset (Pmode, hard_frame_pointer_rtx,
-                         stack_pointer_rtx, callee_offset,
+                         stack_pointer_rtx, chain_offset,
                          tmp1_rtx, tmp0_rtx, frame_pointer_needed);

But the later REG_CFA_ADJUST_CFA handling still used callee_offset.

I think the difference is harmless, but it's more logical for the
CFA note to be in sync, and it's more convenient for later patches
if it uses chain_offset.

gcc/
* config/aarch64/aarch64.cc (aarch64_expand_prologue): Use
chain_offset rather than callee_offset.

22 months agoaarch64: Use local frame vars in shrink-wrapping code
Richard Sandiford [Tue, 12 Sep 2023 15:08:48 +0000 (16:08 +0100)] 
aarch64: Use local frame vars in shrink-wrapping code

aarch64_layout_frame uses a shorthand for referring to
cfun->machine->frame:

  aarch64_frame &frame = cfun->machine->frame;

This patch does the same for some other heavy users of the structure.
No functional change intended.

gcc/
* config/aarch64/aarch64.cc (aarch64_save_callee_saves): Use
a local shorthand for cfun->machine->frame.
(aarch64_restore_callee_saves, aarch64_get_separate_components):
(aarch64_process_components): Likewise.
(aarch64_allocate_and_probe_stack_space): Likewise.
(aarch64_expand_prologue, aarch64_expand_epilogue): Likewise.
(aarch64_layout_frame): Use existing shorthand for one more case.

22 months agors6000: call vector load/store with length only on 64-bit Power10
Haochen Gui [Tue, 12 Sep 2023 01:56:13 +0000 (09:56 +0800)] 
rs6000: call vector load/store with length only on 64-bit Power10

gcc/
PR target/96762
* config/rs6000/rs6000-string.cc (expand_block_move): Call vector
load/store with length only on 64-bit Power10.

gcc/testsuite/
PR target/96762
* gcc.target/powerpc/pr96762.c: New.

(cherry picked from commit 946b8967b905257ac9f140225db744c9a6ab91be)

22 months agoDaily bump.
GCC Administrator [Tue, 12 Sep 2023 00:19:37 +0000 (00:19 +0000)] 
Daily bump.

22 months agoRemove constraint modifier % for fcmaddcph/fmaddcph/fcmulcph since there're not commu...
liuhongt [Fri, 8 Sep 2023 01:22:43 +0000 (09:22 +0800)] 
Remove constraint modifier % for fcmaddcph/fmaddcph/fcmulcph since there're not commutative.

gcc/ChangeLog:

PR target/111306
PR target/111335
* config/i386/sse.md (int_comm): New int_attr.
(fma_<complexopname>_<mode><sdc_maskz_name><round_name>):
Remove % for Complex conjugate operations since they're not
commutative.
(fma_<complexpairopname>_<mode>_pair): Ditto.
(<avx512>_<complexopname>_<mode>_mask<round_name>): Ditto.
(cmul<conj_op><mode>3): Ditto.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit f197392a16ffb1327f1d12ff8ff05f9295e015cb)

22 months agoDaily bump.
GCC Administrator [Mon, 11 Sep 2023 00:18:38 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 10 Sep 2023 00:18:47 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 9 Sep 2023 00:18:46 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 8 Sep 2023 09:43:32 +0000 (09:43 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Thu, 7 Sep 2023 00:19:12 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Wed, 6 Sep 2023 00:19:15 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Tue, 5 Sep 2023 13:35:57 +0000 (13:35 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Mon, 4 Sep 2023 00:18:55 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 3 Sep 2023 00:18:44 +0000 (00:18 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 2 Sep 2023 00:19:38 +0000 (00:19 +0000)] 
Daily bump.

23 months agoomp-expand.cc: Fix wrong code with non-rectangular loop nest [PR111017]
Tobias Burnus [Sat, 19 Aug 2023 05:49:06 +0000 (07:49 +0200)] 
omp-expand.cc: Fix wrong code with non-rectangular loop nest [PR111017]

Before commit r12-5295-g47de0b56ee455e, all gimple_build_cond in
expand_omp_for_* were inserted with
  gsi_insert_before (gsi_p, cond_stmt, GSI_SAME_STMT);
except the one dealing with the multiplicative factor that was
  gsi_insert_after (gsi, cond_stmt, GSI_CONTINUE_LINKING);

That commit for PR103208 fixed the issue of some missing regimplify of
operands of GIMPLE_CONDs by moving the condition handling to the new function
expand_omp_build_cond. While that function has an 'bool after = false'
argument to switch between the two variants.

However, all callers ommited this argument. This commit reinstates the
prior behavior by passing 'true' for the factor != 0 condition, fixing
the included testcase.

PR middle-end/111017
gcc/
* omp-expand.cc (expand_omp_for_init_vars): Pass after=true
to expand_omp_build_cond for 'factor != 0' condition, resulting
in pre-r12-5295-g47de0b56ee455e code for the gimple insert.

libgomp/
* testsuite/libgomp.c-c++-common/non-rect-loop-1.c: New test.

(cherry picked from commit 1dc65003b66e5a97200f454eeddcccfce34416b3)

23 months agoLoongArch: Fix bug in loongarch_emit_stack_tie [PR110484].
Lulu Cheng [Thu, 29 Jun 2023 11:30:59 +0000 (19:30 +0800)] 
LoongArch: Fix bug in loongarch_emit_stack_tie [PR110484].

Which may result in implicit references to $fp when frame_pointer_needed is false,
causing regs_ever_live[$fp] to be true when $fp is not explicitly used,
resulting in $fp being used as the target replacement register in the rnreg pass.

The bug originates from SPEC2017 541.leela_r(-flto).

gcc/ChangeLog:

PR target/110484
* config/loongarch/loongarch.cc (loongarch_emit_stack_tie): Use the
frame_pointer_needed to determine whether to use the $fp register.

Co-authored-by: Guo Jie <guojie@loongson.cn>
(cherry picked from commit 1967f21d000e09d3d3190317af7923b578ce02b1)

23 months agoDaily bump.
GCC Administrator [Fri, 1 Sep 2023 00:19:15 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Thu, 31 Aug 2023 00:21:51 +0000 (00:21 +0000)] 
Daily bump.

23 months agotree-ssa-strlen: Fix up handling of conditionally zero memcpy [PR110914]
Jakub Jelinek [Wed, 30 Aug 2023 09:21:45 +0000 (11:21 +0200)] 
tree-ssa-strlen: Fix up handling of conditionally zero memcpy [PR110914]

The following testcase is miscompiled since r279392 aka r10-5451-gef29b12cfbb4979
The strlen pass has adjust_last_stmt function, which performs mainly strcat
or strcat-like optimizations (say strcpy (x, "abcd"); strcat (x, p);
or equivalent memcpy (x, "abcd", strlen ("abcd") + 1); char *q = strchr (x, 0);
memcpy (x, p, strlen (p)); etc. where the first stmt stores '\0' character
at the end but next immediately overwrites it and so the first memcpy can be
adjusted to store 1 fewer bytes.  handle_builtin_memcpy called this function
in two spots, the first one guarded like:
  if (olddsi != NULL
      && tree_fits_uhwi_p (len)
      && !integer_zerop (len))
    adjust_last_stmt (olddsi, stmt, false);
i.e. only for constant non-zero length.  The other spot can call it even
for non-constant length but in that case we punt before that if that length
isn't length of some string + 1, so again non-zero.
The r279392 change I assume wanted to add some warning stuff and changed it
like
   if (olddsi != NULL
-      && tree_fits_uhwi_p (len)
       && !integer_zerop (len))
-    adjust_last_stmt (olddsi, stmt, false);
+    {
+      maybe_warn_overflow (stmt, len, rvals, olddsi, false, true);
+      adjust_last_stmt (olddsi, stmt, false);
+    }
While maybe_warn_overflow possibly handles non-constant length fine,
adjust_last_stmt really relies on length to be non-zero, which
!integer_zerop (len) alone doesn't guarantee.  While we could for
len being SSA_NAME ask the ranger or tree_expr_nonzero_p, I think
adjust_last_stmt will not benefit from it much, so the following patch
just restores the above condition/previous behavior for the adjust_last_stmt
call only.

2023-08-30  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/110914
* tree-ssa-strlen.cc (strlen_pass::handle_builtin_memcpy): Don't call
adjust_last_stmt unless len is known constant.

* gcc.c-torture/execute/pr110914.c: New test.

(cherry picked from commit 398842e7038ea0f34054f0f694014d0ecd656846)

23 months agostore-merging: Fix up >= 64 bit insertion [PR111015]
Jakub Jelinek [Wed, 30 Aug 2023 08:47:21 +0000 (10:47 +0200)] 
store-merging: Fix up >= 64 bit insertion [PR111015]

The following testcase shows that we mishandle bit insertion for
info->bitsize >= 64.  The problem is in using unsigned HOST_WIDE_INT
shift + subtraction + build_int_cst to compute mask, the shift invokes
UB at compile time for info->bitsize 64 and larger and e.g. on the testcase
with info->bitsize happens to compute mask of 0x3f rather than
0x3f'ffffffff'ffffffff.

The patch fixes that by using wide_int wi::mask + wide_int_to_tree, so it
handles masks in any precision (up to WIDE_INT_MAX_PRECISION ;) ).

2023-08-30  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/111015
* gimple-ssa-store-merging.cc
(imm_store_chain_info::output_merged_store): Use wi::mask and
wide_int_to_tree instead of unsigned HOST_WIDE_INT shift and
build_int_cst to build BIT_AND_EXPR mask.

* gcc.dg/pr111015.c: New test.

(cherry picked from commit 49a3b35c4068091900b657cd36e5cffd41ef0c47)

23 months agoDaily bump.
GCC Administrator [Wed, 30 Aug 2023 00:20:16 +0000 (00:20 +0000)] 
Daily bump.

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

23 months agoDaily bump.
GCC Administrator [Mon, 28 Aug 2023 00:20:55 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sun, 27 Aug 2023 00:19:17 +0000 (00:19 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Sat, 26 Aug 2023 00:20:46 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Fri, 25 Aug 2023 00:20:31 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Thu, 24 Aug 2023 00:20:00 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Wed, 23 Aug 2023 00:20:44 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Tue, 22 Aug 2023 00:20:41 +0000 (00:20 +0000)] 
Daily bump.

23 months agoDaily bump.
GCC Administrator [Mon, 21 Aug 2023 00:19:43 +0000 (00:19 +0000)] 
Daily bump.