aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2021-08-31 11:41:57 +0100
committerRoger Sayle <roger@nextmovesoftware.com>2021-08-31 11:41:57 +0100
commit0960d937d9bee3c831d0b64a9c828c263a58ff89 (patch)
tree5eec37166dd537c7521583df9a08120c749e57c1 /gcc/combine.c
parent67927342290c61d7e054430f1d7a7281f1f97fae (diff)
downloadgcc-0960d937d9bee3c831d0b64a9c828c263a58ff89.zip
gcc-0960d937d9bee3c831d0b64a9c828c263a58ff89.tar.gz
gcc-0960d937d9bee3c831d0b64a9c828c263a58ff89.tar.bz2
Only simplify TRUNCATE to SUBREG on TRULY_NOOP_TRUNCATION targets.
As recently remarked by Jeff Law, SUBREGs are the "forever chemicals" of GCC's RTL; once created they persist in the environment. The problem, according to the comment on lines 5428-5438 of combine.c is that non-tieable SUBREGs interfere with reload/register allocation, so combine often doesn't touch/clean-up instructions containing a SUBREG. This is the first and simplest of two patches to tackle that problem, by teaching combine to avoid converting explicit TRUNCATEs into SUBREGs that it can't handle. Consider the following (hypothetical) sequence of instructions on a STORE_FLAG_VALUE=1 target, which stores a zero or one in an SI register, then uselessly truncates to QImode, then extends it again. (set (reg:SI 27) (ne:SI (reg:BI 28) (const_int 0))) (set (reg:QI 26) (truncate:QI (reg:SI 27))) (set (reg:SI 0) (zero_extend:SI (reg:QI 26))) which ideally (i.e. with this patch) combine would simplify to: (set (reg:SI 0) (ne:SI (reg:BI 28) (const_int 0))) Alas currently, during combine the middle TRUNCATE is converted into a lowpart SUBREG, which subst then turns into (clobber (const_int 0)), abandoning the attempted combination, that then never reaches recog. 2021-08-31 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * combine.c (combine_simplify_rtx): Avoid converting an explicit TRUNCATE into a lowpart SUBREG on !TRULY_NOOP_TRUNCATION targets. * simplify-rtx.c (simplify_unary_operation_1): Likewise.
Diffstat (limited to 'gcc/combine.c')
-rw-r--r--gcc/combine.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index cb5fa40..290a366 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -5903,7 +5903,8 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest,
if (HWI_COMPUTABLE_MODE_P (mode)
&& (STORE_FLAG_VALUE & ~GET_MODE_MASK (mode)) == 0
&& (temp = get_last_value (XEXP (x, 0)))
- && COMPARISON_P (temp))
+ && COMPARISON_P (temp)
+ && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (XEXP (x, 0))))
return gen_lowpart (mode, XEXP (x, 0));
break;