]> git.ipfire.org Git - thirdparty/gcc.git/commit
cse: Fix up CSE const_anchor handling [PR108193]
authorJakub Jelinek <jakub@redhat.com>
Thu, 22 Dec 2022 11:44:13 +0000 (12:44 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 3 May 2023 11:51:46 +0000 (13:51 +0200)
commit14cb8af5a6a1f09250a207359535399fedbbb4ff
treeb597da12ebebf173e090622f66237f7e762b7b0f
parent2a8357535300e9d4d6126d7b3ce4cd951f0eb6aa
cse: Fix up CSE const_anchor handling [PR108193]

The following testcase ICEs on aarch64, because insert_const_anchor
inserts invalid CONST_INT into the CSE tables - 0x80000000 for SImode.
The second hunk of the patch fixes that, the first one is to avoid
triggering undefined behavior at compile time during compute_const_anchors
computations - performing those additions and subtractions in
HOST_WIDE_INT means it can overflow for certain constants.

2022-12-22  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/108193
* cse.c (compute_const_anchors): Change n type to
unsigned HOST_WIDE_INT, adjust comparison against it to avoid
warnings.  Formatting fix.
(insert_const_anchor): Use gen_int_mode instead of GEN_INT.

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

(cherry picked from commit 0cb5d7cdbab8e5f8359764ef5f62d93c2bc88552)
gcc/cse.c
gcc/testsuite/gfortran.dg/pr108193.f90 [new file with mode: 0644]