This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: GCC Status Report (2004-03-09)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Eric Botcazou <ebotcazou at libertysurf dot fr>
- Cc: Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 1 Apr 2004 08:21:28 -0500
- Subject: Re: GCC Status Report (2004-03-09)
- References: <200403091809.i29I9P04020607@sirius.codesourcery.com> <200403310952.36188.ebotcazou@libertysurf.fr> <406AF8DE.4070706@codesourcery.com> <200403311940.36296.ebotcazou@libertysurf.fr>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Mar 31, 2004 at 07:41:18PM +0200, Eric Botcazou wrote:
> > I've been suggesting things, and you've been implementing them, and then
> > not liking them for a couple of weeks now.
>
> I think there was kind of a miscommunication: I thought you wanted to explore
> other ways to fix the problem (that's how I interpreted your latest "Status
> report" message), in particular the clear-only-holes approach that I'm not
> willing to implement myself just before the release.
>
> > Somehow, we've got to get a fix into the compiler.
>
> Sure.
>
> > What do you suggest?
>
> Let's post a last "call for patches" message, wait a couple of days and then
> apply the 2 patches.
I tested the patches overnight on {i386,x86_64,ia64,ppc,ppc64,s390,s390x}.
There was one regression, particularly 20030408-1.c on IA-64 at -O1 and
above. test2(), test3() and test4() abort ().
For 20030408-1.c no barrier is created, but as shown by the attached patch,
even if the barrier is created, it doesn't help much (well, the test below
fails even without your patch).
Say for test1 below, the resulting code does:
*(long *)&X = 0; // /u store
*(short *)((char *)&X + 8) = 0; // /u store
asm_input ("");
X.c = 'C'; // /u store
*(short *)(buffer + 8) = 0;
X.e = 'E'; // /u store
X.g = 'G'; // /u store
X.a = 'A'; // /u store
X.i = 'I'; // /u store
*(long *)buffer = *(long *)&X; // note: non-/u read
I'll debug this further.
Is the test eventually ok for trunk/3.4?
2004-04-01 Jakub Jelinek <jakub@redhat.com>
PR optimization/8634
* gcc.c-torture/execute/20040401-1.c: New test.
--- gcc/testsuite/gcc.c-torture/execute/20040401-1.c.jj 2004-01-21 17:12:41.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/execute/20040401-1.c 2004-04-01 14:17:14.651476184 +0200
@@ -0,0 +1,74 @@
+/* PR optimization/8634 */
+
+extern void abort (void);
+
+struct foo {
+ const char a, b, c, d, e, f, g, h, i, j;
+};
+
+struct bar {
+ const char a, b, c, d, e, f, g, h, i;
+ char j;
+};
+
+int test1 ()
+{
+ struct foo X = { a : 'A', c : 'C', e : 'E', g : 'G', i : 'I' };
+ char buffer[10];
+ __builtin_memcpy (buffer, &X, 10);
+ if (buffer[0] != 'A' || buffer[1] != '\0'
+ || buffer[2] != 'C' || buffer[3] != '\0'
+ || buffer[4] != 'E' || buffer[5] != '\0'
+ || buffer[6] != 'G' || buffer[7] != '\0'
+ || buffer[8] != 'I' || buffer[9] != '\0')
+ abort ();
+ return 0;
+}
+
+int test2 ()
+{
+ struct bar X = { a : 'A', c : 'C', e : 'E', g : 'G', i : 'I' };
+ char buffer[10];
+ __builtin_memcpy (buffer, &X, 10);
+ if (buffer[0] != 'A' || buffer[1] != '\0'
+ || buffer[2] != 'C' || buffer[3] != '\0'
+ || buffer[4] != 'E' || buffer[5] != '\0'
+ || buffer[6] != 'G' || buffer[7] != '\0'
+ || buffer[8] != 'I' || buffer[9] != '\0')
+ abort ();
+ return 0;
+}
+
+int test3 ()
+{
+ struct foo X = { .b = 'B', .d = 'D', .f = 'F', .h = 'H' , .j = 'J' };
+ char buffer[10];
+ __builtin_memcpy (buffer, &X, 10);
+ if (buffer[0] != '\0' || buffer[1] != 'B'
+ || buffer[2] != '\0' || buffer[3] != 'D'
+ || buffer[4] != '\0' || buffer[5] != 'F'
+ || buffer[6] != '\0' || buffer[7] != 'H'
+ || buffer[8] != '\0' || buffer[9] != 'J')
+ abort ();
+ return 0;
+}
+
+int test4 ()
+{
+ struct bar X = { .b = 'B', .d = 'D', .f = 'F', .h = 'H' , .j = 'J' };
+ char buffer[10];
+ __builtin_memcpy (buffer, &X, 10);
+ if (buffer[0] != '\0' || buffer[1] != 'B'
+ || buffer[2] != '\0' || buffer[3] != 'D'
+ || buffer[4] != '\0' || buffer[5] != 'F'
+ || buffer[6] != '\0' || buffer[7] != 'H'
+ || buffer[8] != '\0' || buffer[9] != 'J')
+ abort ();
+ return 0;
+}
+
+int main ()
+{
+ test1 (); test2 (); test3 (); test4 ();
+ return 0;
+}
Jakub