Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: George France <france@handhelds.org>
Cc: axp-list@redhat.com
Subject: Re: unaligned traps question
Date: 17 Oct 2002 20:37:21 +0200	[thread overview]
Message-ID: <87d6q87vz2.fsf@student.uni-tuebingen.de> (raw)
In-Reply-To: <02101616080803.18457@shadowfax.middleearth>

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

George France <france@handhelds.org> writes:

> On Wednesday 16 October 2002 15:45, Falk Hueffner wrote:
> > Note that the code gcc generates for these is pretty inefficient,
> > though, so the memcpy method is probably faster. (Incidentally, I have
> > a patch lying around that makes better code on Alphas with the BWX
> > extension, but I never got around to finishing it... does anybody
> > think it is worthwhile?)
> 
> Yup, pretty may not equal fast. :-)  Maybe Alvin would like to test this
> and let us know?
> 
> Lots of people could take advantage of the BWX extension.  For people
> with those systems it is probably worthwhile.

OK, here it is... if anybody likes it, I could try to submit it to the
gcc maintainers.

-- 
	Falk


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: unaligned.patch --]
[-- Type: text/x-patch, Size: 2844 bytes --]

Index: alpha.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/alpha/alpha.c,v
retrieving revision 1.277
diff -u -r1.277 alpha.c
--- alpha.c	27 Sep 2002 13:30:07 -0000	1.277
+++ alpha.c	17 Oct 2002 18:10:53 -0000
@@ -4075,9 +4075,15 @@
            lda    r3,X(r11)                lda    r3,X+2(r11)
            extwl  r1,r3,r1                 extql  r1,r3,r1
            extwh  r2,r3,r2                 extqh  r2,r3,r2
-           or     r1.r2.r1                 or     r1,r2,r1
+           or     r1,r2,r1                 or     r1,r2,r1
                                            sra    r1,48,r1
 
+   (BWX)   ldbu   r1,X(a0)                 ldbu   r1,X(a0)
+           ldbu   r2,X+1(a0)               ldbu   r2,X+1(a0)
+           sll    r2,8,r2                  sll    r2,8,r2
+           or     r1,r2,r1                 or     r1,r2,r1
+                                           sextwl r1,r1
+
    long:   ldq_u  r1,X(r11)                ldq_u  r1,X(r11)
            ldq_u  r2,X+3(r11)              ldq_u  r2,X+3(r11)
            lda    r3,X(r11)                lda    r3,X(r11)
@@ -4102,6 +4108,26 @@
   rtx meml, memh, addr, extl, exth, tmp, mema;
   enum machine_mode mode;
 
+  if (TARGET_BWX && (int) size == 2)
+    {
+      rtx lo, hi;
+
+      lo = gen_reg_rtx (QImode);      
+      hi = gen_reg_rtx (QImode); 
+      emit_move_insn (lo, adjust_address (mem, QImode, 
+					  ofs + WORDS_BIG_ENDIAN ? 1 : 0));
+      emit_move_insn (hi, adjust_address (mem, QImode, 
+					  ofs + WORDS_BIG_ENDIAN ? 0 : 1));
+      tmp = expand_binop (HImode, ashl_optab, hi, GEN_INT (8), 
+			  tgt, 0, OPTAB_WIDEN);
+      tmp = expand_binop (HImode, ior_optab, lo, tmp, 
+			  tgt, 0, OPTAB_WIDEN);
+
+      if (tmp != tgt)
+	emit_move_insn (tgt, gen_lowpart(GET_MODE (tgt), tmp));
+      return;
+    }
+
   meml = gen_reg_rtx (DImode);
   memh = gen_reg_rtx (DImode);
   addr = gen_reg_rtx (DImode);
@@ -4225,7 +4251,26 @@
      HOST_WIDE_INT size, ofs;
 {
   rtx dstl, dsth, addr, insl, insh, meml, memh, dsta;
-  
+
+  /* For small data types (short and int), it's faster to write out byte-wise,
+     since that doesn't require any loads.  */
+
+  if (TARGET_BWX && (int) size <= 4)
+    {
+      int i;
+      for (i = 0; i < size; i++)
+        {
+          rtx ext = gen_reg_rtx (DImode);
+          expand_binop (DImode, lshr_optab, src, GEN_INT (i * 8),
+                        ext, 1, OPTAB_WIDEN);
+          emit_move_insn (adjust_address (dst, QImode,
+                                          ofs + (WORDS_BIG_ENDIAN
+                                                 ? size - i : i)),
+                          gen_lowpart(QImode, ext));
+        }
+      return;
+    }
+
   dstl = gen_reg_rtx (DImode);
   dsth = gen_reg_rtx (DImode);
   insl = gen_reg_rtx (DImode);

  reply	other threads:[~2002-10-17 18:36 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-15  0:50 unaligned traps question Ram Viswanadha
2002-10-15  1:38 ` Michal Jaegermann
2002-10-15  2:03 ` Uncle George
2002-10-15 15:39   ` George France
2002-10-15 16:46     ` Michal Jaegermann
2002-10-15 18:24       ` alvin
2002-10-15 19:33         ` George France
2002-10-15 19:40         ` Falk Hueffner
     [not found]         ` <3DAC6EF2.BC962839@voicenet.com>
2002-10-16 18:15           ` alvin
2002-10-16 19:18             ` George France
2002-10-16 19:45               ` Falk Hueffner
2002-10-16 20:08                 ` George France
2002-10-17 18:37                   ` Falk Hueffner [this message]
2002-10-16 20:23             ` Michal Jaegermann
2002-10-16 21:30               ` alvin
2002-10-17  1:47             ` Uncle George
2002-10-15 18:08     ` Uncle George
2002-10-15 19:29       ` George France
2002-10-15 20:10         ` Uncle George
2002-10-15 20:46           ` George France
2002-10-15 15:33 ` George France
2002-10-17 22:17   ` Ram Viswanadha
2002-10-18 15:36     ` Michal Jaegermann
2002-10-18 17:17       ` Ram Viswanadha
2002-10-18 18:47         ` Michal Jaegermann
     [not found] <673E0A4C-E1DF-11D6-AC80-000393768D2C@mcgillsociety.org>
2002-10-17 15:50 ` George France
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox