This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add -meb to two Octeon tests


Richard Sandiford writes:
> Adam Nemet <anemet@caviumnetworks.com> writes:
> > Richard Sandiford writes:
> >> Adam Nemet <anemet@caviumnetworks.com> writes:
> >> > There are two tests that fail when compiled for little-endian.
> >> >
> >> > octeon-exts-2.c is more obvious.  In this structure:
> >> >
> >> > struct bar 
> >> > { 
> >> >   unsigned long long a:1; 
> >> >   long long b:14; 
> >> >   unsigned long long c:48; 
> >> >   long long d:1; 
> >> > }; 
> >> >
> >> > when d is extracted, it is the bottom bit in big-endian but the top bit in
> >> > little-endian.  If d is the top bit then signed extraction can be achieved
> >> > equally well with a arithmetic right shift.
> >> 
> >> Since we're still supposed to be able to use this instruction for
> >> _some_ code on little endian targets, I'd prefer that we either:
> >> 
> >>   (a) apply your patch but create an -mel-friendly version too.
> >>   (b) reverse the order of the fields when _MIPSEL is defined.
> >> 
> >> The first is better really.  (I know it must seem daft having
> >> -mel Octeon tests, but it isn't a rejected combination.)
> >
> > Since one of the cases in this test is meant to verify extraction of the
> > bottom bit I went with (b) here.  (Also note that there are other exts tests
> > already that are -mel-friendly.)
> 
> I'm not sure from your reply whether this was clear or not, so just to
> be on the safe side: the idea with (a) was to copy the test to a new
> file and replace the structure definition with the _MIPSEL version.
> The old test would then require -meb and the new one would require -mel.
> The idea is that someone testing without endianness options (which is
> the usual case on IRIX and GNU/Linux) would still end up running both
> the -meb and -mel tests.

Yes, I did misunderstand.  I thought that when you said '-mel-friendly' you
meant endian agnostic.  Here is the patch to split the test along your idea.
You're right, it clearly provides better coverage.

> s/futher/further/

Done.

Retested the octeon-exts-[25] tests with
{,-mabi=32,-mabi=n32,-mabi=64,-meb,-mel,-mel\ -mabi=32,-mips16\ -mabi=32}.

OK?

	* gcc.target/mips/octeon-exts-2.c: Compile it with -meb.
	* gcc.target/mips/octeon-exts-5.c: New test.
	* gcc.target/mips/octeon-bbit-3.c: Compile with -meb.  Add
	comment why this is necessary.

Index: gcc.target/mips/octeon-exts-2.c
===================================================================
--- gcc.target/mips/octeon-exts-2.c	(revision 140961)
+++ gcc.target/mips/octeon-exts-2.c	(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-mips-options "-O -march=octeon" } */
+/* { dg-mips-options "-O -march=octeon -meb" } */
 /* { dg-final { scan-assembler-times "\texts\t" 4 } } */
 
 struct bar
Index: gcc.target/mips/octeon-exts-5.c
===================================================================
--- gcc.target/mips/octeon-exts-5.c	(revision 0)
+++ gcc.target/mips/octeon-exts-5.c	(revision 0)
@@ -0,0 +1,38 @@
+/* -mel version of octeon-exts-2.c.  */
+/* { dg-do compile } */
+/* { dg-mips-options "-O -march=octeon -mel" } */
+/* { dg-final { scan-assembler-times "\texts\t" 4 } } */
+
+struct bar
+{
+  long long d:1;
+  unsigned long long c:48;
+  long long b:14;
+  unsigned long long a:1;
+};
+
+NOMIPS16 int
+f1 (struct bar *s, int a)
+{
+  return (int) s->b + a;
+}
+
+NOMIPS16 char
+f2 (struct bar *s)
+{
+  return s->d + 1;
+}
+
+NOMIPS16 int
+f3 ()
+{
+  struct bar s;
+  asm ("" : "=r"(s));
+  return (int) s.b + 1;
+}
+
+NOMIPS16 long long
+f4 (struct bar *s)
+{
+  return s->d;
+}
Index: gcc.target/mips/octeon-bbit-3.c
===================================================================
--- gcc.target/mips/octeon-bbit-3.c	(revision 140961)
+++ gcc.target/mips/octeon-bbit-3.c	(working copy)
@@ -1,5 +1,18 @@
 /* { dg-do compile } */
-/* { dg-mips-options "-O2 -march=octeon" } */
+
+/* Force big-endian because for little-endian, combine generates this:
+
+ (if_then_else (ne (zero_extract:DI (subreg:DI (truncate:SI (reg:DI 196)) 0) 
+                 (const_int 1) 
+                 (const_int 0)) 
+             (const_int 0)) 
+         (label_ref 20) 
+         (pc))) 
+
+  which does not get recognized as a valid bbit pattern.  The
+  middle-end should be able to simplify this further.  */
+/* { dg-mips-options "-O2 -march=octeon -meb" } */
+
 /* { dg-final { scan-assembler-times "\tbbit\[01\]\t|\tbgez\t" 2 } } */
 /* { dg-final { scan-assembler-not "ext\t" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]