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

            Bug ID: 59865
           Summary: gnu multiversion calculates wrong target
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mib.bugzilla at gmail dot com

According to the gnu multiversion wiki, if a target function is specified with
arch=corei7, and another taret function is specified with "popcnt", then the
arch= function should win, because corei7 supports popcnt as well.

however, gcc 4.8.1 is choosing the popcnt target, not the corei7 target.

Do you expect this discrepancy will be fixed?

Test case:
cat corei7.C
#include <cstdio>
int __attribute__ ((target("default")))
foo() { puts("default wins\n"); }

int __attribute__((target("arch=corei7")))
foo() { puts("corei7 wins\n"); }

int __attribute__((target("popcnt")))
foo() { puts("popcnt wins\n"); }

int main ()
{
  int val = foo ();
  return 0;
}
-bash-4.1$ g++ corei7.C
-bash-4.1$ ./a.out
popcnt wins

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/rdrive/ref/gcc/4.8.1/rhel60/efi2/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with:
/rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/configure
--prefix=/rdrive/ref/gcc/4.8.1/rhel60/efi2
--enable-languages=c,c++,objc,fortran --disable-multilib --enable-bootstrap
--target=x86_64-unknown-linux-gnu --disable-bootstrap --enable-decimal-float
--with-gmp=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2
--with-mpfr=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2
--with-mpc=/rusers/sys_cron/grab_gcc/downloads_rel/lib/efi2
Thread model: posix
gcc version 4.8.1 (GCC)

Quoting the wiki: 
When a function version with target attribute "arch=<processor X>" is compared
with a function version with attribute "<ISA Y>", then the highest priority of
the any ISA supported by processor X is compared to the priority of ISA Y to
decide which version should be dispatched first. If the priorities are the same
then the version with "arch=" is given precedence. For instance, when comparing
"arch=corei7" and "popcnt", "arch=corei7" wins since the priority of the
highest ISA supported by corei7 is popcnt.

Reply via email to