http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57333

            Bug ID: 57333
           Summary: Wrong detection of LZCNT instruction, -mno-lzcnt has
                    no effect
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernhard.hartleb at gmail dot com

Sorry for describing two issues here, but I cant say how they are related:

1st: When using -march=native, gcc tries to use the LZCNT instruction. However
the CPUID of my processor does not show that this instruction is supported.

2nd: Trying to work around this, I noticed that -mno-lzcnt has no effect. When
using -march=amdfam10 (or native in my case) LZCNT will always be used and can
NOT be disabled.

Version:
gcc (Gentoo 4.7.3 p1.0, pie-0.5.5) 4.7.3

Relevant parts of /proc/cpuinfo:
vendor_id       : AuthenticAMD
cpu family      : 16
model           : 4
model name      : AMD Phenom(tm) II X4 810 Processor
stepping        : 2
microcode       : 0x10000c6
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb
rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid pni
monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a
misalignsse 3dnowprefetch osvw ibs skinit wdt hw_pstate npt lbrv svm_lock
nrip_save

(POPCNT is supported but LZCNT is not)

Testcase for the error:
$ echo | gcc -dM -E - -march=amdfam10 -mno-lzcnt | grep LZCNT
#define __LZCNT__ 1

Expected behaviour (like for POPCNT)
$ echo | gcc -dM -E - -march=amdfam10 -mno-popcnt | grep POP
(No output)

To sum it up: LZCNT is not detected correctly and can not be controlled.

Reply via email to