Patchwork [Comitted] Add testcase for some miscompile in older versions of GCC

login
register
mail settings
Submitter Andrew Pinski
Date Aug. 30, 2014, 10:35 p.m.
Message ID <CA+=Sn1mwo2sbG62X5b8rrj9w=w=kO+XhjmDLnZFgBz0rpTDJYg@mail.gmail.com>
Download mbox | patch
Permalink /patch/384514/
State New
Headers show

Comments

Andrew Pinski - Aug. 30, 2014, 10:35 p.m.
Hi,
  In some versions of GCC with AARCH64 backported, I got a miscompile
of a shift that involved a load which had a post increment of the
address.  This adds the testcase I created for that case.

Comitted after a quick test on x86_64-linux-gnu of the testcase.  I
had meant to commit this two days which is why the testcase is dated
two days ago.

Thanks,
Andrew Pinski

ChangeLog:
* gcc.c-torture/execute/20140828-1.c: New testcase.

Patch

Index: gcc.c-torture/execute/20140828-1.c
===================================================================
--- gcc.c-torture/execute/20140828-1.c	(revision 0)
+++ gcc.c-torture/execute/20140828-1.c	(revision 0)
@@ -0,0 +1,22 @@ 
+short *f(short *a, int b, int *d) __attribute__((noinline,noclone));
+
+short *f(short *a, int b, int *d)
+{
+  short c = *a;
+  a++;
+  c = b << c;
+  *d = c;
+  return a;
+}
+
+int main(void)
+{
+  int d;
+  short a[2];
+  a[0] = 0;
+  if (f(a, 1, &d) != &a[1])
+    __builtin_abort ();
+  if (d != 1)
+    __builtin_abort ();
+  return 0;
+}