aboutsummaryrefslogtreecommitdiff
path: root/gcc/dse.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2020-11-30 17:15:47 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2020-11-30 17:15:47 +0000
commitf835e9f6562dda9c8a1384be2c9d4e45c112ed8e (patch)
treeb3bcb6699585eb436eefd158a7a49722e65b0c43 /gcc/dse.c
parent28a7fdd81e857057f18f87a3c9dd180ad99b77f6 (diff)
downloadgcc-f835e9f6562dda9c8a1384be2c9d4e45c112ed8e.zip
gcc-f835e9f6562dda9c8a1384be2c9d4e45c112ed8e.tar.gz
gcc-f835e9f6562dda9c8a1384be2c9d4e45c112ed8e.tar.bz2
dse: Cope with bigger-than-integer modes [PR98037]
dse.c:find_shift_sequence tries to represent a store and load back as a shift right followed by a truncation. It therefore needs to find an integer mode in which to do the shift right. The loop it uses has the form: FOR_EACH_MODE_FROM (new_mode_iter, smallest_int_mode_for_size (GET_MODE_BITSIZE (read_mode))) which implicitly assumes that read_mode has an equivalent integer mode. As shown in the testcase, not all modes have such an integer mode. This patch just makes the code start from the smallest integer mode and skip modes that are too small. The loop already breaks at the first mode wider than word_mode. gcc/ PR rtl-optimization/98037 * dse.c (find_shift_sequence): Iterate over all integers and skip modes that are too small. gcc/testsuite/ PR rtl-optimization/98037 * gcc.target/aarch64/sve/acle/general/pr98037.c: New test.
Diffstat (limited to 'gcc/dse.c')
-rw-r--r--gcc/dse.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/dse.c b/gcc/dse.c
index d65266b..651e6e7 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -1757,8 +1757,7 @@ find_shift_sequence (poly_int64 access_size,
the machine. */
opt_scalar_int_mode new_mode_iter;
- FOR_EACH_MODE_FROM (new_mode_iter,
- smallest_int_mode_for_size (GET_MODE_BITSIZE (read_mode)))
+ FOR_EACH_MODE_IN_CLASS (new_mode_iter, MODE_INT)
{
rtx target, new_reg, new_lhs;
rtx_insn *shift_seq, *insn;
@@ -1767,6 +1766,8 @@ find_shift_sequence (poly_int64 access_size,
new_mode = new_mode_iter.require ();
if (GET_MODE_BITSIZE (new_mode) > BITS_PER_WORD)
break;
+ if (maybe_lt (GET_MODE_SIZE (new_mode), GET_MODE_SIZE (read_mode)))
+ continue;
/* Try a wider mode if truncating the store mode to NEW_MODE
requires a real instruction. */