This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59865] gnu multiversion calculates wrong target
- From: "mib.bugzilla at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 20 Jan 2014 15:00:37 +0000
- Subject: [Bug c++/59865] gnu multiversion calculates wrong target
- Auto-submitted: auto-generated
- References: <bug-59865-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59865
--- Comment #2 from mib.bugzilla at gmail dot com ---
Thanks. I realized after I posted that the test case isn't definitive. Improved
test case pasted below.
Inspection of the assembly listing shows that popcnt is being checked before
arch=corei7. I was testing to see the precendence of arch= versus isa by
creating foo for all isa, then seeing where a single arch= is sorted in the
dispatch function.
cat core-pop.C
#include <assert.h>
#include <string.h>
#include <cstdio>
const char * __attribute__ ((target("default"))) foo(void)
{ return("default wins\n");}
const char* __attribute__ ((target("arch=corei7"))) foo(void)
{ return("corei7 wins\n");}
const char* __attribute__ ((target("popcnt"))) foo(void)
{ return("popcnt wins\n");}
int main ()
{
const char *result = foo ();
if (__builtin_cpu_is ("corei7")) puts("builtin cpu is corei7\n");
if (__builtin_cpu_is ("corei7"))
assert ( 0 == strcmp(result, "corei7 wins"));
return 0;
}
-bash-4.1$ g++ core-pop.C -S
-bash-4.1$ g++ core-pop.C
-bash-4.1$ grep movl core-pop.s | grep foov //From dispatch function
movl $_Z3foov.popcnt, %eax
movl $_Z3foov.arch_corei7, %eax
movl $_Z3foov, %eax
-bash-4.1$ ./a.out
builtin cpu is corei7
a.out: core-pop.C:15: int main(): Assertion `0 == strcmp(result, "corei7
wins")' failed.
Aborted (core dumped)