Darwin uses a different spelling for popcnt (popcnt instead of popcntw). Check for this in the test.
tested on x86_64-darwin16 and x86_64-linux-gnu (--target_board=unix\{-m32,-m64\}\{,-fpic\}) aplied to mainline, thanks Iain 2019-05-25 Iain Sandoe <i...@sandoe.co.uk> * gcc.target/i386/pr59874-3.c: Use the spelling of popcnt expected for Darwin. diff --git a/gcc/testsuite/gcc.target/i386/pr59874-3.c b/gcc/testsuite/gcc.target/i386/pr59874-3.c index ec55a12..0332f04 100644 --- a/gcc/testsuite/gcc.target/i386/pr59874-3.c +++ b/gcc/testsuite/gcc.target/i386/pr59874-3.c @@ -1,7 +1,8 @@ /* PR target/59874 */ /* { dg-do compile } */ /* { dg-options "-O2 -mpopcnt -masm=att" } */ -/* { dg-final { scan-assembler "popcntw" } } */ +/* { dg-final { scan-assembler "\tpopcntw" { target { ! *-*-darwin* } } } } */ +/* { dg-final { scan-assembler "\tpopcnt" { target *-*-darwin* } } } */ unsigned int foo (unsigned short x)