diff options
author | Roger Sayle <roger@nextmovesoftware.com> | 2023-12-11 17:30:20 +0000 |
---|---|---|
committer | Roger Sayle <roger@nextmovesoftware.com> | 2023-12-11 17:32:35 +0000 |
commit | 624e274ca3a4405a55662fa72d1163120df0e03d (patch) | |
tree | 0de4c3d22ea011aa0b425fc106bc65c0bd55755d /gcc/combine.cc | |
parent | 02f562484c17522d79a482ac702a5fa3c2dfdd10 (diff) | |
download | gcc-624e274ca3a4405a55662fa72d1163120df0e03d.zip gcc-624e274ca3a4405a55662fa72d1163120df0e03d.tar.gz gcc-624e274ca3a4405a55662fa72d1163120df0e03d.tar.bz2 |
PR rtl-optimization/112380: Defend against CLOBBERs in combine.cc
This patch addresses PR rtl-optimization/112380, an ICE-on-valid regression
where a (clobber (const_int 0)) encounters a sanity checking gcc_assert
(at line 7554) in simplify-rtx.cc. These CLOBBERs are used internally
by GCC's combine pass much like error_mark_node is used by various
language front-ends.
The solutions are either to handle/accept these CLOBBERs through-out
(or in more places in) the middle-end's RTL optimizers, including functions
in simplify-rtx.cc that are used by passes other than combine, and/or
attempt to prevent these CLOBBERs escaping from try_combine into the
RTX/RTL stream. The benefit of the second approach is that it actually
allows for better optimization: when try_combine fails to simplify an
expression instead of substituting a CLOBBER to avoid the instruction
pattern being recognized, noticing the CLOBBER often allows combine
to attempt alternate simplifications/transformations looking for those
that can be recognized.
This first alternative is the minimal fix to address the CLOBBER
encountered in the bugzilla PR.
2023-12-11 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR rtl-optimization/112380
* combine.cc (expand_field_assignment): Check if gen_lowpart
returned a CLOBBER, and avoid calling gen_simplify_binary with
it if so.
gcc/testsuite/ChangeLog
PR rtl-optimization/112380
* gcc.dg/pr112380.c: New test case.
Diffstat (limited to 'gcc/combine.cc')
-rw-r--r-- | gcc/combine.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/combine.cc b/gcc/combine.cc index 6344cd3..f2c64a9 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -7466,6 +7466,11 @@ expand_field_assignment (const_rtx x) if (!targetm.scalar_mode_supported_p (compute_mode)) break; + /* gen_lowpart_for_combine returns CLOBBER on failure. */ + rtx lowpart = gen_lowpart (compute_mode, SET_SRC (x)); + if (GET_CODE (lowpart) == CLOBBER) + break; + /* Now compute the equivalent expression. Make a copy of INNER for the SET_DEST in case it is a MEM into which we will substitute; we don't want shared RTL in that case. */ @@ -7480,9 +7485,7 @@ expand_field_assignment (const_rtx x) inner); masked = simplify_gen_binary (ASHIFT, compute_mode, simplify_gen_binary ( - AND, compute_mode, - gen_lowpart (compute_mode, SET_SRC (x)), - mask), + AND, compute_mode, lowpart, mask), pos); x = gen_rtx_SET (copy_rtx (inner), |