public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix length computation of single bit bitfield extraction on H8
@ 2023-12-10 17:08 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-12-10 17:08 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]


Various approaches are used to optimize extracting a sign extended 
single bit bitfield.  The length computation of 10 bytes was 
conservatively correct, but inaccurate.

In particular when the bit we want is in the low half word we don't need 
the move high half to low half instruction.  Account for that in the 
length computation.

This was spotted when looking at regressions in the generalized signed 
bitfield extraction pattern.

This has been regression tested on the H8 port.

Pushing to the trunk,
Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 1491 bytes --]

commit 1f55c5cc698519094f751257db62ff274c015fdc
Author: Jeff Law <jlaw@ventanamicro.com>
Date:   Sun Dec 10 10:05:18 2023 -0700

    [committed] Fix length computation of single bit bitfield extraction on H8
    
    Various approaches are used to optimize extracting a sign extended single bit
    bitfield.  The length computation of 10 bytes was conservatively correct, but
    inaccurate.
    
    In particular when the bit we want is in the low half word we don't need the
    move high half to low half instruction.  Account for that in the length
    computation.
    
    This was spotted when looking at regressions in the generalized signed bitfield
    extraction pattern.
    
    This has been regression tested on the H8 port.
    
    gcc/
            * config/h8300/combiner.md (single bit signed bitfield extraction): Fix
            length computation when the bit we want is in the low half word.

diff --git a/gcc/config/h8300/combiner.md b/gcc/config/h8300/combiner.md
index e1179b5fea6..cce187805c7 100644
--- a/gcc/config/h8300/combiner.md
+++ b/gcc/config/h8300/combiner.md
@@ -1358,7 +1358,7 @@ (define_insn ""
      to get that bit into the destination, properly extended.  */
   return "subx\t%s0,%s0\;exts.w %T0\;exts.l %0";
 }
-  [(set_attr "length" "10")])
+  [(set (attr "length") (symbol_ref "INTVAL (operands[2]) >= 16 ? 10 : 8"))])
 
 ;; For shift counts >= 16 we can always do better than the
 ;; generic sequences.  Other patterns handle smaller counts.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-10 17:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-10 17:08 [committed] Fix length computation of single bit bitfield extraction on H8 Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).