[committed] Add a bswap testcase
diff mbox series

Message ID CA+=Sn1ns6BLLbgtPj2DQ_LmQQUBFscjJiHgBN3uzSpWFMp9u4w@mail.gmail.com
State New
Headers show
Series
  • [committed] Add a bswap testcase
Related show

Commit Message

Andrew Pinski Dec. 8, 2019, 9:59 p.m. UTC
Hi,
  While testing a GCC patch (which I am not ready to submit yet), I
wrote a testcase which had produced wrong code (with an earlier
version of the patch).  There was no other testcase for it in the
testsuite so I adding one.
This is a reduced testcase from the uboot PCIe code.


Thanks,
Andrew Pinski

* gcc.c-torture/execute/bswap-3.c: New testcase.

Patch
diff mbox series

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 279099)
+++ ChangeLog	(working copy)
@@ -1,3 +1,7 @@ 
+2019-12-08  Andrew Pinski  <apinski@marvell.com>
+
+	* gcc.c-torture/execute/bswap-3.c: New test.
+
 2019-12-08  Sandra Loosemore  <sandra@codesourcery.com>
 
 	Revert:
Index: gcc.c-torture/execute/bswap-3.c
===================================================================
--- gcc.c-torture/execute/bswap-3.c	(nonexistent)
+++ gcc.c-torture/execute/bswap-3.c	(working copy)
@@ -0,0 +1,25 @@ 
+/* { dg-require-effective-target int32plus } */
+
+int f(unsigned int a) __attribute__((noipa));
+int f(unsigned int a)
+{
+  return ((__builtin_bswap32(a))>>24) & 0x3;
+}
+
+
+int g(unsigned int a) __attribute__((noipa));
+int g(unsigned int a)
+{
+  return a&0x3;
+}
+
+int main(void)
+{
+  for (int b = 0; b <= 0xF; b++)
+    {
+      if (f(b) != g(b))
+	__builtin_abort ();
+    }
+  return 0;
+}
+