diff mbox

PATCH: PR target/49128: -mtune=native generates unsupported instructions

Message ID BANLkTinB35F=V_nNdzRxS1mL8Fc+zoUsnA@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu May 23, 2011, 6:25 p.m. UTC
On Mon, May 23, 2011 at 11:16 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, May 23, 2011 at 11:10:26AM -0700, H.J. Lu wrote:
>> +      const char *sse4_2 = has_sse4_2 ? " -msse4.2" : " -msse4.2";
>> +      const char *sse4_1 = has_sse4_1 ? " -msse4.1" : " -msse4.1";
>
> Missing "no-" here on both lines.
>

Here is the updated patch.  It also handles FMA.  OK for trunk and 4.6
if there are no regressions?

Comments

Uros Bizjak May 24, 2011, 5:19 p.m. UTC | #1
On Mon, May 23, 2011 at 8:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>> +      const char *sse4_2 = has_sse4_2 ? " -msse4.2" : " -msse4.2";
>>> +      const char *sse4_1 = has_sse4_1 ? " -msse4.1" : " -msse4.1";
>>
>> Missing "no-" here on both lines.
>>
>
> Here is the updated patch.  It also handles FMA.  OK for trunk and 4.6
> if there are no regressions?
>
>
> --
> H.J.
> ----
> 2011-05-23  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR target/49128
>        * config/i386/driver-i386.c (host_detect_local_cpu): Always
>        add -mno-XXX.  Handle FMA.

OK.

Thanks,
Uros.
Tobias Burnus May 25, 2011, 6:20 a.m. UTC | #2
This patch caused a boot-strap failure as it should be -mno-sse4.2 and 
not -mno-msse4.2,  cf. http://gcc.gnu.org/ml/gcc/2011-05/msg00271.html

H.J. Lu wrote:
> Here is the updated patch.  It also handles FMA.  OK for trunk and 4.6
> if there are no regressions?
[...]

> 2011-05-23  H.J. Lu<hongjiu.lu@intel.com>
>
> 	PR target/49128
> 	* config/i386/driver-i386.c (host_detect_local_cpu): Always
> 	add -mno-XXX.  Handle FMA.
[...]
> +      const char *sse4_2 = has_sse4_2 ? " -msse4.2" : " -mno-msse4.2";


Tobias
diff mbox

Patch

2011-05-23  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/49128
	* config/i386/driver-i386.c (host_detect_local_cpu): Always
	add -mno-XXX.  Handle FMA.

diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c
index 35962c8..747122b 100644
--- a/gcc/config/i386/driver-i386.c
+++ b/gcc/config/i386/driver-i386.c
@@ -395,7 +395,7 @@  const char *host_detect_local_cpu (int argc, const char **argv)
   unsigned int has_movbe = 0, has_sse4_1 = 0, has_sse4_2 = 0;
   unsigned int has_popcnt = 0, has_aes = 0, has_avx = 0;
   unsigned int has_pclmul = 0, has_abm = 0, has_lwp = 0;
-  unsigned int has_fma4 = 0, has_xop = 0;
+  unsigned int has_fma = 0, has_fma4 = 0, has_xop = 0;
   unsigned int has_bmi = 0, has_tbm = 0;
 
   bool arch;
@@ -443,6 +443,7 @@  const char *host_detect_local_cpu (int argc, const char **argv)
   has_popcnt = ecx & bit_POPCNT;
   has_aes = ecx & bit_AES;
   has_pclmul = ecx & bit_PCLMUL;
+  has_fma = ecx & bit_FMA;
 
   has_cmpxchg8b = edx & bit_CMPXCHG8B;
   has_cmov = edx & bit_CMOV;
@@ -681,37 +682,26 @@  const char *host_detect_local_cpu (int argc, const char **argv)
 
   if (arch)
     {
-      if (has_cmpxchg16b)
-	options = concat (options, " -mcx16", NULL);
-      if (has_lahf_lm)
-	options = concat (options, " -msahf", NULL);
-      if (has_movbe)
-	options = concat (options, " -mmovbe", NULL);
-      if (has_aes)
-	options = concat (options, " -maes", NULL);
-      if (has_pclmul)
-	options = concat (options, " -mpclmul", NULL);
-      if (has_popcnt)
-	options = concat (options, " -mpopcnt", NULL);
-      if (has_abm)
-	options = concat (options, " -mabm", NULL);
-      if (has_lwp)
-	options = concat (options, " -mlwp", NULL);
-      if (has_fma4)
-	options = concat (options, " -mfma4", NULL);
-      if (has_xop)
-	options = concat (options, " -mxop", NULL);
-      if (has_bmi)
-	options = concat (options, " -mbmi", NULL);
-      if (has_tbm)
-	options = concat (options, " -mtbm", NULL);
-
-      if (has_avx)
-	options = concat (options, " -mavx", NULL);
-      else if (has_sse4_2)
-	options = concat (options, " -msse4.2", NULL);
-      else if (has_sse4_1)
-	options = concat (options, " -msse4.1", NULL);
+      const char *cx16 = has_cmpxchg16b ? " -mcx16" : " -mno-cx16";
+      const char *sahf = has_lahf_lm ? " -msahf" : " -mno-sahf";
+      const char *movbe = has_movbe ? " -mmovbe" : " -mno-movbe";
+      const char *ase = has_aes ? " -maes" : " -mno-aes";
+      const char *pclmul = has_pclmul ? " -mpclmul" : " -mno-pclmul";
+      const char *popcnt = has_popcnt ? " -mpopcnt" : " -mno-popcnt";
+      const char *abm = has_abm ? " -mabm" : " -mno-abm";
+      const char *lwp = has_lwp ? " -mlwp" : " -mno-lwp";
+      const char *fma = has_fma ? " -mfma" : " -mno-fma";
+      const char *fma4 = has_fma4 ? " -mfma4" : " -mno-fma4";
+      const char *xop = has_xop ? " -mxop" : " -mno-xop";
+      const char *bmi = has_bmi ? " -mbmi" : " -mno-bmi";
+      const char *tbm = has_tbm ? " -mtbm" : " -mno-tbm";
+      const char *avx = has_avx ? " -mavx" : " -mno-avx";
+      const char *sse4_2 = has_sse4_2 ? " -msse4.2" : " -mno-msse4.2";
+      const char *sse4_1 = has_sse4_1 ? " -msse4.1" : " -mno-sse4.1";
+
+      options = concat (options, cx16, sahf, movbe, ase, pclmul,
+			popcnt, abm, lwp, fma, fma4, xop, bmi, tbm,
+			avx, sse4_2, sse4_1, NULL);
     }
 
 done: