Re: [PATCH][i386] Add -march=native support for VIA nano CPUs

2016-05-31 Thread J. Mayer
On Tue, 2016-05-31 at 13:38 +0200, Uros Bizjak wrote:
> On Mon, May 30, 2016 at 12:09 AM, J. Mayer  wrote:
> > 
> > Hello,
> > 
> > On Sun, 2016-05-29 at 21:12 +0200, Uros Bizjak wrote:
> > > 
> > > Hello!
> > > 
> > > > 
> > > > 
> > > > When trying to compile using -march=native on a VIA nano CPU,
> > > > gcc
> > > > selects "-march=core2" "-mtune=i386" then is unable to compile,
> > > > as
> > > > this
> > > > creates a conflicts between 32 bits and 64 bits compilation
> > > > modes,
> > > > as
> > > > show by the following test:
> > > [...]
> > > 
> > > > 
> > > > 
> > > > --- gcc/config/i386/driver-i386.c.origÂÂ2015-02-02
> > > > 05:20:49.0
> > > > +0100
> > > > +++ gcc/config/i386/driver-i386.cÂÂÂ2015-08-23
> > > > 01:11:03.0
> > > > +0200
> > > > @@ -601,15 +601,20 @@
> > > > ÂÂswitch (family)
> > > > {
> > > > case 6:
> > > > -Âif (model > 9)
> > > The patch was corrupted by your mailer. But - can you please open
> > > a
> > > bugreport, and refer reposted patch to this bugreport? This way,
> > > the
> > > problem (and the patch) won't get forgotten.
> > > 
> > > Uros.
> > > 
> > Sorry for that, might be because of UTF-8 encoding.
> > I already opened a bug many monthes ago, ID 67310:
> > 
> > I just updated the patch against current git repository, the only
> > difference between previous versions are diff offsets.
> Can you please test the patch that is attached to the bugreport?
> 
> Thanks,
> Uros.

Yes, I've seen your patch and downloaded it, I'm now recompiling gcc
from patched git repository; I'll be busy in the hours to come, but
I'll make the test as soon as I can.

Jocelyn



Re: [PATCH][i386] Add -march=native support for VIA nano CPUs

2016-05-31 Thread Uros Bizjak
On Mon, May 30, 2016 at 12:09 AM, J. Mayer  wrote:
> Hello,
>
> On Sun, 2016-05-29 at 21:12 +0200, Uros Bizjak wrote:
>> Hello!
>>
>> >
>> > When trying to compile using -march=native on a VIA nano CPU, gcc
>> > selects "-march=core2" "-mtune=i386" then is unable to compile, as
>> > this
>> > creates a conflicts between 32 bits and 64 bits compilation modes,
>> > as
>> > show by the following test:
>> [...]
>>
>> >
>> > --- gcc/config/i386/driver-i386.c.origÂÂ2015-02-02
>> > 05:20:49.0
>> > +0100
>> > +++ gcc/config/i386/driver-i386.cÂÂÂ2015-08-23
>> > 01:11:03.0
>> > +0200
>> > @@ -601,15 +601,20 @@
>> > ÂÂswitch (family)
>> > {
>> > case 6:
>> > -Âif (model > 9)
>> The patch was corrupted by your mailer. But - can you please open a
>> bugreport, and refer reposted patch to this bugreport? This way, the
>> problem (and the patch) won't get forgotten.
>>
>> Uros.
>>
>
> Sorry for that, might be because of UTF-8 encoding.
> I already opened a bug many monthes ago, ID 67310:
> 
> I just updated the patch against current git repository, the only
> difference between previous versions are diff offsets.

Can you please test the patch that is attached to the bugreport?

Thanks,
Uros.


Re: [PATCH][i386] Add -march=native support for VIA nano CPUs

2016-05-29 Thread J. Mayer
Hello,

On Sun, 2016-05-29 at 21:12 +0200, Uros Bizjak wrote:
> Hello!
> 
> > 
> > When trying to compile using -march=native on a VIA nano CPU, gcc
> > selects "-march=core2" "-mtune=i386" then is unable to compile, as
> > this
> > creates a conflicts between 32 bits and 64 bits compilation modes,
> > as
> > show by the following test:
> [...]
> 
> > 
> > --- gcc/config/i386/driver-i386.c.origÂÂ2015-02-02
> > 05:20:49.0
> > +0100
> > +++ gcc/config/i386/driver-i386.cÂÂÂ2015-08-23
> > 01:11:03.0
> > +0200
> > @@ -601,15 +601,20 @@
> > ÂÂswitch (family)
> > {
> > case 6:
> > -Âif (model > 9)
> The patch was corrupted by your mailer. But - can you please open a
> bugreport, and refer reposted patch to this bugreport? This way, the
> problem (and the patch) won't get forgotten.
> 
> Uros.
> 

Sorry for that, might be because of UTF-8 encoding.
I already opened a bug many monthes ago, ID 67310:

I just updated the patch against current git repository, the only
difference between previous versions are diff offsets.

Jocelyn

---

diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-
i386.c
index b121466..662709e 100644
--- a/gcc/config/i386/driver-i386.c
+++ b/gcc/config/i386/driver-i386.c
@@ -642,15 +642,20 @@ const char *host_detect_local_cpu (int argc,
const char **argv)
  switch (family)
{
case 6:
- if (model > 9)
-   /* Use the default detection procedure.  */
+ if (has_longmode)
processor = PROCESSOR_GENERIC;
- else if (model == 9)
-   cpu = "c3-2";
- else if (model >= 6)
-   cpu = "c3";
  else
-   processor = PROCESSOR_GENERIC;
+   {
+ if (model > 9)
+   /* Use the default detection procedure.  */
+   processor = PROCESSOR_GENERIC;
+ else if (model == 9)
+   cpu = "c3-2";
+ else if (model >= 6)
+   cpu = "c3";
+ else
+   processor = PROCESSOR_GENERIC;
+   }
  break;
case 5:
  if (has_3dnow)
@@ -664,6 +669,8 @@ const char *host_detect_local_cpu (int argc, const
char **argv)
  /* We have no idea.  */
  processor = PROCESSOR_GENERIC;
}
+   } else {
+ processor = PROCESSOR_GENERIC;
}
 }
   else
@@ -894,7 +901,12 @@ const char *host_detect_local_cpu (int argc, const
char **argv)
   if (arch)
{
  if (has_ssse3)
-   cpu = "core2";
+   {
+ if (vendor == signature_CENTAUR_ebx)
+   cpu = "x86-64";
+ else
+   cpu = "core2";
+   }
  else if (has_sse3)
{
  if (has_longmode)



Re: [PATCH][i386] Add -march=native support for VIA nano CPUs

2016-05-29 Thread Uros Bizjak
Hello!

> When trying to compile using -march=native on a VIA nano CPU, gcc
> selects "-march=core2" "-mtune=i386" then is unable to compile, as this
> creates a conflicts between 32 bits and 64 bits compilation modes, as
> show by the following test:

[...]

> --- gcc/config/i386/driver-i386.c.origÂÂ2015-02-02 05:20:49.0
> +0100
> +++ gcc/config/i386/driver-i386.cÂÂÂ2015-08-23 01:11:03.0
> +0200
> @@ -601,15 +601,20 @@
> ÂÂswitch (family)
> {
> case 6:
> -Âif (model > 9)

The patch was corrupted by your mailer. But - can you please open a
bugreport, and refer reposted patch to this bugreport? This way, the
problem (and the patch) won't get forgotten.

Uros.


[PATCH][i386] Add -march=native support for VIA nano CPUs

2016-05-29 Thread J. Mayer
When trying to compile using -march=native on a VIA nano CPU, gcc
selects "-march=core2" "-mtune=i386" then is unable to compile, as this
creates a conflicts between 32 bits and 64 bits compilation modes, as
show by the following test:

# echo 'int main(){return 0;}' > test.c && gcc -march=native -O2
-pipe  test.c -o test && rm test.c test
Compilation fails with the following error message and informations:
[...]
test.c:1:0: error: CPU you selected does not support x86-64 instruction
set
 int main(){return 0;}
 ^

Using "-v -Q" option shows the detection problem:
gnu/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.8.4/
 test.c -march=core2 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul
 -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi
 -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-
lzcnt
 -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed
 -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt
 --param l1-cache-size=64 --param l1-cache-line-size=64
 --param l2-cache-size=1024 -mtune=i386 -O2 -fno-use-linker-plugin


The following patch allows gcc to select correct compilation options,
which can be checked using "-v -Q" gcc options. GCC output becomes:
gnu/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.8.4/
 test.c -march=x86-64 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul
 -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi
 -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -msse3 -mssse3 -mno-sse4.2
 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c
 -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave
 -mno-xsaveopt --param l1-cache-size=64 --param l1-cache-line-size=64
 --param l2-cache-size=1024 -mtune=generic -O2 -fno-use-linker-plugin

which seems OK.
The same problem appears with gcc 4.9.3 and 5.2, and likely with
current git version.

The following patch applies to gcc >= 4.9; it has been tested by
recompiling the whole system from scratch on a Gentoo distribution
using gcc version 4.9.3 (the current stable gcc version on Gentoo
x86_64) with no issue.

Please consider applying this patch to future releases.

Jocelyn Mayer 

PS: please CC me to any answer to this mail, as I didn't subscribe to
the mailing list.

---

--- gcc/config/i386/driver-i386.c.orig  2015-02-02 05:20:49.0
+0100
+++ gcc/config/i386/driver-i386.c   2015-08-23 01:11:03.0
+0200
@@ -601,15 +601,20 @@
  switch (family)
{
case 6:
- if (model > 9)
-   /* Use the default detection procedure.  */
+ if (has_longmode)
processor = PROCESSOR_GENERIC;
- else if (model == 9)
-   cpu = "c3-2";
- else if (model >= 6)
-   cpu = "c3";
  else
-   processor = PROCESSOR_GENERIC;
+   {
+ if (model > 9)
+   /* Use the default detection procedure.  */
+   processor = PROCESSOR_GENERIC;
+ else if (model == 9)
+   cpu = "c3-2";
+ else if (model >= 6)
+   cpu = "c3";
+ else
+   processor = PROCESSOR_GENERIC;
+   }
  break;
case 5:
  if (has_3dnow)
@@ -623,6 +628,8 @@
  /* We have no idea.  */
  processor = PROCESSOR_GENERIC;
}
+   } else {
+ processor = PROCESSOR_GENERIC;
}
 }
   else
@@ -840,7 +847,12 @@
   if (arch)
{ 
  if (has_ssse3)
-   cpu = "core2";
+   {
+ if (vendor == signature_CENTAUR_ebx)
+   cpu = "x86-64";
+ else
+   cpu = "core2";
+   }
  else if (has_sse3)
{ 
  if (has_longmode)