aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Law <jlaw@ventanamicro.com>2023-12-10 09:32:55 -0700
committerJeff Law <jlaw@ventanamicro.com>2023-12-10 09:32:55 -0700
commit4ac358c619e364ad767242409765c178da9d83e0 (patch)
treea7bcda2d899f1c8026e67c3546a9fe946bf6537f
parentfbfe43daec6443978df65530dc5f7f3f8a4e6f9e (diff)
downloadgcc-4ac358c619e364ad767242409765c178da9d83e0.zip
gcc-4ac358c619e364ad767242409765c178da9d83e0.tar.gz
gcc-4ac358c619e364ad767242409765c178da9d83e0.tar.bz2
[committed] Fix length computation for logical shifts on H8
This fixes the length computation for logical shifts on the H8/SX. The H8/SX has a richer set of logical shifts compared to early parts in the H8 family. It has special 2 byte instructions for shifts by power of two immediate values as well as a special 4 byte shift by other immediate values. These were never accounted for (AFIACT) in the length computation for shifts. Until now that's mostly just affected branch shortening. But an upcoming patch uses instruction lengths to select between two potential sequences and getting these lengths wrong will cause it to miss optimization opportunities on the H8/SX. gcc * config/h8300/h8300.cc (compute_a_shift_length): Fix computation of logical shifts on the H8/SX.
-rw-r--r--gcc/config/h8300/h8300.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/config/h8300/h8300.cc b/gcc/config/h8300/h8300.cc
index 5936cdc..5f9bbc9 100644
--- a/gcc/config/h8300/h8300.cc
+++ b/gcc/config/h8300/h8300.cc
@@ -4299,6 +4299,11 @@ compute_a_shift_length (rtx operands[3], rtx_code code)
/* Fall through. */
case SHIFT_INLINE:
+ /* H8/SX has a richer set of logical shifts. */
+ if (TARGET_H8300SX
+ && (code == ASHIFT || code == LSHIFTRT))
+ return (exact_log2 (n) >= 0) ? 2 : 4;
+
n = info.remainder;
if (info.shift2 != NULL)