Patchwork [i386] cpuid function for prefetchw

login
register
mail settings
Submitter Jakub Jelinek
Date Aug. 13, 2012, 9:45 a.m.
Message ID <20120813094536.GI1999@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/176894/
State New
Headers show

Comments

Jakub Jelinek - Aug. 13, 2012, 9:45 a.m.
On Mon, Aug 13, 2012 at 09:29:45AM +0000, Gopalasubramanian, Ganesh wrote:
> To get the prefetchw cpuid flag, cpuid
> function 0x80000001 needs to be called.
> Previous to patch, function 0x7 is called.
> 
> Bootstrapping and "make -k check" passes without failures.
> Ok for trunk?

IMHO you move it to a wrong spot, ecx bits of CPUID 0x80000001 are tested
earlier.

So I think you want this instead (bootstrap/regtest in progress):

2012-08-13  Ganesh Gopalasubramanian  <Ganesh.Gopalasubramanian@amd.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR driver/54210
	* config/i386/driver-i386.c (host_detect_local_cpu): Test bit_PRFCHW
	bit of CPUID 0x80000001 %ecx instead of CPUID 7 %ecx.
	* config/i386/cpuid.h (bits_PRFCHW): Move definition to CPUID
	0x80000001 %ecx flags.



	Jakub
Jakub Jelinek - Aug. 13, 2012, 12:10 p.m.
On Mon, Aug 13, 2012 at 11:45:36AM +0200, Jakub Jelinek wrote:
> On Mon, Aug 13, 2012 at 09:29:45AM +0000, Gopalasubramanian, Ganesh wrote:
> > To get the prefetchw cpuid flag, cpuid
> > function 0x80000001 needs to be called.
> > Previous to patch, function 0x7 is called.
> > 
> > Bootstrapping and "make -k check" passes without failures.
> > Ok for trunk?
> 
> IMHO you move it to a wrong spot, ecx bits of CPUID 0x80000001 are tested
> earlier.
> 
> So I think you want this instead (bootstrap/regtest in progress):
> 
> 2012-08-13  Ganesh Gopalasubramanian  <Ganesh.Gopalasubramanian@amd.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR driver/54210
> 	* config/i386/driver-i386.c (host_detect_local_cpu): Test bit_PRFCHW
> 	bit of CPUID 0x80000001 %ecx instead of CPUID 7 %ecx.
> 	* config/i386/cpuid.h (bits_PRFCHW): Move definition to CPUID
> 	0x80000001 %ecx flags.

Now bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

	Jakub
Uros Bizjak - Aug. 13, 2012, 12:59 p.m.
On Mon, Aug 13, 2012 at 2:10 PM, Jakub Jelinek <jakub@redhat.com> wrote:

>> > To get the prefetchw cpuid flag, cpuid
>> > function 0x80000001 needs to be called.
>> > Previous to patch, function 0x7 is called.
>> >
>> > Bootstrapping and "make -k check" passes without failures.
>> > Ok for trunk?
>>
>> IMHO you move it to a wrong spot, ecx bits of CPUID 0x80000001 are tested
>> earlier.
>>
>> So I think you want this instead (bootstrap/regtest in progress):
>>
>> 2012-08-13  Ganesh Gopalasubramanian  <Ganesh.Gopalasubramanian@amd.com>
>>           Jakub Jelinek  <jakub@redhat.com>
>>
>>       PR driver/54210
>>       * config/i386/driver-i386.c (host_detect_local_cpu): Test bit_PRFCHW
>>       bit of CPUID 0x80000001 %ecx instead of CPUID 7 %ecx.
>>       * config/i386/cpuid.h (bits_PRFCHW): Move definition to CPUID
>>       0x80000001 %ecx flags.
>
> Now bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK, but I didn't find PRFCHW in the cpuid documentation to confirm the change.

Thanks,
Uros.
H.J. Lu - Aug. 13, 2012, 1:06 p.m.
On Mon, Aug 13, 2012 at 5:59 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Mon, Aug 13, 2012 at 2:10 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>
>>> > To get the prefetchw cpuid flag, cpuid
>>> > function 0x80000001 needs to be called.
>>> > Previous to patch, function 0x7 is called.
>>> >
>>> > Bootstrapping and "make -k check" passes without failures.
>>> > Ok for trunk?
>>>
>>> IMHO you move it to a wrong spot, ecx bits of CPUID 0x80000001 are tested
>>> earlier.
>>>
>>> So I think you want this instead (bootstrap/regtest in progress):
>>>
>>> 2012-08-13  Ganesh Gopalasubramanian  <Ganesh.Gopalasubramanian@amd.com>
>>>           Jakub Jelinek  <jakub@redhat.com>
>>>
>>>       PR driver/54210
>>>       * config/i386/driver-i386.c (host_detect_local_cpu): Test bit_PRFCHW
>>>       bit of CPUID 0x80000001 %ecx instead of CPUID 7 %ecx.
>>>       * config/i386/cpuid.h (bits_PRFCHW): Move definition to CPUID
>>>       0x80000001 %ecx flags.
>>
>> Now bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> OK, but I didn't find PRFCHW in the cpuid documentation to confirm the change.
>
> Thanks,
> Uros.

It is in Intel AVX spec:

http://software.intel.com/en-us/avx/

Patch

--- gcc/config/i386/driver-i386.c.jj	2012-08-10 15:49:25.000000000 +0200
+++ gcc/config/i386/driver-i386.c	2012-08-13 11:30:14.570494736 +0200
@@ -467,7 +467,6 @@  const char *host_detect_local_cpu (int a
       has_bmi2 = ebx & bit_BMI2;
       has_fsgsbase = ebx & bit_FSGSBASE;
       has_rdseed = ebx & bit_RDSEED;
-      has_prfchw = ecx & bit_PRFCHW;
       has_adx = ebx & bit_ADX;
     }
 
@@ -488,6 +487,7 @@  const char *host_detect_local_cpu (int a
       has_xop = ecx & bit_XOP;
       has_tbm = ecx & bit_TBM;
       has_lzcnt = ecx & bit_LZCNT;
+      has_prfchw = ecx & bit_PRFCHW;
 
       has_longmode = edx & bit_LM;
       has_3dnowp = edx & bit_3DNOWP;
--- gcc/config/i386/cpuid.h.jj	2012-08-10 15:49:25.000000000 +0200
+++ gcc/config/i386/cpuid.h	2012-08-13 11:31:30.346494092 +0200
@@ -52,6 +52,7 @@ 
 #define bit_LAHF_LM	(1 << 0)
 #define bit_ABM		(1 << 5)
 #define bit_SSE4a	(1 << 6)
+#define bit_PRFCHW	(1 << 8)
 #define bit_XOP         (1 << 11)
 #define bit_LWP 	(1 << 15)
 #define bit_FMA4        (1 << 16)
@@ -69,7 +70,6 @@ 
 #define bit_HLE	(1 << 4)
 #define bit_AVX2	(1 << 5)
 #define bit_BMI2	(1 << 8)
-#define bit_PRFCHW	(1 << 8)
 #define bit_RTM	(1 << 11)
 #define bit_RDSEED	(1 << 18)
 #define bit_ADX	(1 << 19)