diff mbox

[PR,target/15184] Fix for direct byte access on x86

Message ID CAFULd4b396rJpKAMU1c_Dk1h+zAmH2XgVvVB6RwgQouz3fKNpA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Jan. 30, 2015, 10:07 a.m. UTC
On Fri, Jan 30, 2015 at 7:12 AM, Jeff Law <law@redhat.com> wrote:

>> Hello!
>>
>>> So here's the updated patch which handles all 4 testcases from the PR as
>>> well as a couple of my own.
>>
>>
>> @@ -0,0 +1,33 @@
>> +/* PR 15184 first two tests, plus two addition ones.  */
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2 -m32 -march=pentiumpro" } */
>>
>> No, we don't want -m32 in dg-options. Please write this part as:
>>
>> /* { dg-do compile { target ia32 } } */
>> /* { dg-options "-O2 -march=pentiumpro" } */
>
> Will update after sniff testing.  Sorry for the noise.

I'll commit the attached patch that fixes this and -fpic problem as
soon as regtest finishes.

2015-01-30  Uros Bizjak  <ubizjak@gmail.com>

    * gcc.target/i386/pr15184-1.c: Compile for ia32 target only.
    (dg-options): Remove -m32.
    (dg-final): Scan for "movb %al" only.
    * gcc.target/i386/pr15184-2.c: Ditto.

Uros.

Comments

Jakub Jelinek Jan. 30, 2015, 10:13 a.m. UTC | #1
On Fri, Jan 30, 2015 at 11:07:45AM +0100, Uros Bizjak wrote:
> --- gcc.target/i386/pr15184-1.c	(revision 220273)
> +++ gcc.target/i386/pr15184-1.c	(working copy)
> @@ -1,11 +1,10 @@
>  /* PR 15184 first two tests, plus two addition ones.  */
> -/* { dg-do compile } */
> -/* { dg-options "-O2 -m32 -march=pentiumpro" } */
> +/* { dg-do compile { target ia32 } } */
> +/* { dg-options "-O2 -march=pentiumpro" } */
>  
> -#define regparm __attribute__((__regparm__(3)))
> +#define regparm __attribute__((__regparm__(1)))
>  
>  extern unsigned int x;
> -extern unsigned short y;
>  
>  void regparm f0(unsigned char c)
>  {
> @@ -29,5 +28,5 @@
>  
>  /* Each function should compile down to a byte move from
>     the input register into x, possibly at an offset within x.  */
> -/* { dg-final { scan-assembler-times "\tmovb\t%al, x" 4 } } */
> +/* { dg-final { scan-assembler-times "movb\[ \\t\]+%al" 4 } } */

Shouldn't that better be movb\[^\n\r\]+%al, so that it doesn't
fail with -masm=intel ?

	Jakub
Uros Bizjak Jan. 30, 2015, 10:23 a.m. UTC | #2
On Fri, Jan 30, 2015 at 11:13 AM, Jakub Jelinek <jakub@redhat.com> wrote:

>>  /* Each function should compile down to a byte move from
>>     the input register into x, possibly at an offset within x.  */
>> -/* { dg-final { scan-assembler-times "\tmovb\t%al, x" 4 } } */
>> +/* { dg-final { scan-assembler-times "movb\[ \\t\]+%al" 4 } } */
>
> Shouldn't that better be movb\[^\n\r\]+%al, so that it doesn't
> fail with -masm=intel ?

Unfortunately, -masm=intel emits "mov ..., al". And since there is
already plenty of scan-asms for mov[lq], I just took the easy shortcut
;)

Uros.
Jakub Jelinek Jan. 30, 2015, 10:24 a.m. UTC | #3
On Fri, Jan 30, 2015 at 11:23:38AM +0100, Uros Bizjak wrote:
> On Fri, Jan 30, 2015 at 11:13 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> 
> >>  /* Each function should compile down to a byte move from
> >>     the input register into x, possibly at an offset within x.  */
> >> -/* { dg-final { scan-assembler-times "\tmovb\t%al, x" 4 } } */
> >> +/* { dg-final { scan-assembler-times "movb\[ \\t\]+%al" 4 } } */
> >
> > Shouldn't that better be movb\[^\n\r\]+%al, so that it doesn't
> > fail with -masm=intel ?
> 
> Unfortunately, -masm=intel emits "mov ..., al". And since there is
> already plenty of scan-asms for mov[lq], I just took the easy shortcut
> ;)

Ok, let's consider --target_board=unix/-masm=intel as unsupportable then.

	Jakub
Jeff Law Jan. 30, 2015, 7:43 p.m. UTC | #4
On 01/30/15 03:24, Jakub Jelinek wrote:
> On Fri, Jan 30, 2015 at 11:23:38AM +0100, Uros Bizjak wrote:
>> On Fri, Jan 30, 2015 at 11:13 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>
>>>>   /* Each function should compile down to a byte move from
>>>>      the input register into x, possibly at an offset within x.  */
>>>> -/* { dg-final { scan-assembler-times "\tmovb\t%al, x" 4 } } */
>>>> +/* { dg-final { scan-assembler-times "movb\[ \\t\]+%al" 4 } } */
>>>
>>> Shouldn't that better be movb\[^\n\r\]+%al, so that it doesn't
>>> fail with -masm=intel ?
>>
>> Unfortunately, -masm=intel emits "mov ..., al". And since there is
>> already plenty of scan-asms for mov[lq], I just took the easy shortcut
>> ;)
>
> Ok, let's consider --target_board=unix/-masm=intel as unsupportable then.
Yes, definitely.

jeff
Jeff Law Jan. 30, 2015, 7:47 p.m. UTC | #5
On 01/30/15 03:07, Uros Bizjak wrote:
> On Fri, Jan 30, 2015 at 7:12 AM, Jeff Law <law@redhat.com> wrote:
>
>>> Hello!
>>>
>>>> So here's the updated patch which handles all 4 testcases from the PR as
>>>> well as a couple of my own.
>>>
>>>
>>> @@ -0,0 +1,33 @@
>>> +/* PR 15184 first two tests, plus two addition ones.  */
>>> +/* { dg-do compile } */
>>> +/* { dg-options "-O2 -m32 -march=pentiumpro" } */
>>>
>>> No, we don't want -m32 in dg-options. Please write this part as:
>>>
>>> /* { dg-do compile { target ia32 } } */
>>> /* { dg-options "-O2 -march=pentiumpro" } */
>>
>> Will update after sniff testing.  Sorry for the noise.
>
> I'll commit the attached patch that fixes this and -fpic problem as
> soon as regtest finishes.
>
> 2015-01-30  Uros Bizjak  <ubizjak@gmail.com>
>
>      * gcc.target/i386/pr15184-1.c: Compile for ia32 target only.
>      (dg-options): Remove -m32.
>      (dg-final): Scan for "movb %al" only.
>      * gcc.target/i386/pr15184-2.c: Ditto.
Again, sorry for making work for you.  There's clearly more to the x86 
target tests than meets the eye.  I'll run further additions through you 
until I think I've got my brain wrapped around all things that have to 
be considered for x86 specific tests.

jeff
diff mbox

Patch

Index: gcc.target/i386/pr15184-1.c
===================================================================
--- gcc.target/i386/pr15184-1.c	(revision 220273)
+++ gcc.target/i386/pr15184-1.c	(working copy)
@@ -1,11 +1,10 @@ 
 /* PR 15184 first two tests, plus two addition ones.  */
-/* { dg-do compile } */
-/* { dg-options "-O2 -m32 -march=pentiumpro" } */
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O2 -march=pentiumpro" } */
 
-#define regparm __attribute__((__regparm__(3)))
+#define regparm __attribute__((__regparm__(1)))
 
 extern unsigned int x;
-extern unsigned short y;
 
 void regparm f0(unsigned char c)
 {
@@ -29,5 +28,5 @@ 
 
 /* Each function should compile down to a byte move from
    the input register into x, possibly at an offset within x.  */
-/* { dg-final { scan-assembler-times "\tmovb\t%al, x" 4 } } */
+/* { dg-final { scan-assembler-times "movb\[ \\t\]+%al" 4 } } */
 
Index: gcc.target/i386/pr15184-2.c
===================================================================
--- gcc.target/i386/pr15184-2.c	(revision 220273)
+++ gcc.target/i386/pr15184-2.c	(working copy)
@@ -1,10 +1,9 @@ 
 /* PR 15184 second two tests
-/* { dg-do compile } */
-/* { dg-options "-O2 -m32 -march=pentiumpro" } */
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O2 -march=pentiumpro" } */
 
-#define regparm __attribute__((__regparm__(3)))
+#define regparm __attribute__((__regparm__(1)))
 
-extern unsigned int x;
 extern unsigned short y;
 
 void regparm g0(unsigned char c)
@@ -18,6 +17,6 @@ 
 }
 
 /* Each function should compile down to a byte move from
-   the input register into x, possibly at an offset within x.  */
-/* { dg-final { scan-assembler-times "\tmovb\t%al, y" 2 } } */
+   the input register into y, possibly at an offset within y.  */
+/* { dg-final { scan-assembler-times "movb\[ \\t\]+%al" 2 } } */