From 4ac358c619e364ad767242409765c178da9d83e0 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sun, 10 Dec 2023 09:32:55 -0700 Subject: [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. --- gcc/config/h8300/h8300.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc') 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) -- cgit v1.1