public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Simplify (subreg:SI (lshiftrt:DI (reg:DI A) (const_int 32))  0)
@ 2008-03-03 15:13 Paolo Bonzini
  2008-03-05  2:26 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2008-03-03 15:13 UTC (permalink / raw)
  To: gcc-patches

In other word, remove useless shifts from extractions of words from 
multi-word subregs.  This is common when C code wants the high word of a 
32x32->64 multiplication.

Bootstrapped/regtested i686-pc-linux-gnu, ok for mainline?

Paolo

Index: simplify-rtx.c
===================================================================
--- simplify-rtx.c      (revision 131960)
+++ simplify-rtx.c      (working copy)
@@ -5211,6 +5211,22 @@ simplify_subreg (enum machine_mode outer
      return simplify_gen_binary (ASHIFT, outermode,
                                 XEXP (XEXP (op, 0), 0), XEXP (op, 1));

+  /* Recognize a word extraction from a multi-word subreg.  */
+  if ((GET_CODE (op) == LSHIFTRT
+       || GET_CODE (op) == ASHIFTRT)
+      && SCALAR_INT_MODE_P (outermode)
+      && GET_MODE_BITSIZE (outermode) >= BITS_PER_WORD
+      && GET_MODE_BITSIZE (innermode) >= (2 * GET_MODE_BITSIZE (outermode))
+      && GET_CODE (XEXP (op, 1)) == CONST_INT
+      && (INTVAL (XEXP (op, 1)) & (GET_MODE_BITSIZE (outermode) - 1)) == 0
+      && byte == subreg_lowpart_offset (outermode, innermode))
+    {
+      int shifted_bytes = INTVAL (XEXP (op, 1)) / BITS_PER_UNIT;
+      return simplify_gen_subreg (outermode, XEXP (op, 0), innermode,
+                                 (WORDS_BIG_ENDIAN
+                                  ? byte - shifted_bytes : byte + 
shifted_bytes));
+    }
+
    return NULL_RTX;
  }


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Simplify (subreg:SI (lshiftrt:DI (reg:DI A) (const_int 32))  0)
  2008-03-03 15:13 [PATCH] Simplify (subreg:SI (lshiftrt:DI (reg:DI A) (const_int 32)) 0) Paolo Bonzini
@ 2008-03-05  2:26 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2008-03-05  2:26 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches

Paolo Bonzini <bonzini@gnu.org> writes:

> In other word, remove useless shifts from extractions of words from
> multi-word subregs.  This is common when C code wants the high word of
> a 32x32->64 multiplication.
> 
> Bootstrapped/regtested i686-pc-linux-gnu, ok for mainline?

This is OK with a ChangeLog entry.

Thanks.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-03-05  2:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-03 15:13 [PATCH] Simplify (subreg:SI (lshiftrt:DI (reg:DI A) (const_int 32)) 0) Paolo Bonzini
2008-03-05  2:26 ` Ian Lance Taylor

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).