public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/60847] New: x86 BMI intrinsics not recognized
@ 2014-04-15 16:02 spatel at rotateright dot com
2014-04-15 16:05 ` [Bug c/60847] " spatel at rotateright dot com
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: spatel at rotateright dot com @ 2014-04-15 16:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
Bug ID: 60847
Summary: x86 BMI intrinsics not recognized
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: spatel at rotateright dot com
With gcc 4.9.0 (version details below), the x86 bit manipulation instruction
(BMI) C intrinsics are not being recognized. This appears to be a regression
from gcc 4.8.2.
$ cat bmi.c
#include <x86intrin.h>
int foo(int a) { return _blsmsk_u32(a); }
int foo2(int a) { return _blsr_u32(a); }
$ gcc -O1 bmi.c -mbmi -S -o -
.text
.globl _foo
_foo:
LFB2449:
subq $8, %rsp
LCFI0:
movl $0, %eax
call __blsmsk_u32 <--- this should be a 'blsmsk' instruction
addq $8, %rsp
LCFI1:
ret
LFE2449:
.globl _foo2
_foo2:
LFB2450:
subq $8, %rsp
LCFI2:
movl $0, %eax
call __blsr_u32 <--- this should be a 'blsr' instruction
addq $8, %rsp
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin13/4.9.0/lto-wrapper
Target: x86_64-apple-darwin13
Configured with:
/opt/local/var/macports/build/_opt_mports_dports_lang_gcc49/gcc49/work/gcc-4.9-20140406/configure
--prefix=/opt/local --build=x86_64-apple-darwin13
--enable-languages=c,c++,objc,obj-c++,fortran,java
--libdir=/opt/local/lib/gcc49 --includedir=/opt/local/include/gcc49
--infodir=/opt/local/share/info --mandir=/opt/local/share/man
--datarootdir=/opt/local/share/gcc-4.9 --with-local-prefix=/opt/local
--with-system-zlib --disable-nls --program-suffix=-mp-4.9
--with-gxx-include-dir=/opt/local/include/gcc49/c++/ --with-gmp=/opt/local
--with-mpfr=/opt/local --with-mpc=/opt/local --with-cloog=/opt/local
--enable-cloog-backend=isl --disable-cloog-version-check
--enable-stage1-checking --disable-multilib --enable-lto
--enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld
--with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket
--with-pkgversion='MacPorts gcc49 4.9-20140406_0'
Thread model: posix
gcc version 4.9.0 20140406 (experimental) (MacPorts gcc49 4.9-20140406_0)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/60847] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
@ 2014-04-15 16:05 ` spatel at rotateright dot com
2014-04-15 16:13 ` [Bug target/60847] " jakub at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: spatel at rotateright dot com @ 2014-04-15 16:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
--- Comment #1 from Sanjay Patel <spatel at rotateright dot com> ---
It looks like an extra leading underscore is required to recognize the BMI
intrinsics. This is not happening with other (BMI2, SSE4) intrinsics.
According to the Intel reference docs and previous versions of gcc, a single
underscore is the correct usage.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/60847] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
2014-04-15 16:05 ` [Bug c/60847] " spatel at rotateright dot com
@ 2014-04-15 16:13 ` jakub at gcc dot gnu.org
2014-04-15 16:17 ` [Bug c/60847] " spatel at rotateright dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-15 16:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |kyukhin at gcc dot gnu.org
Component|c |target
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
These were added to 4.8 branch with r201047, but I can't find corresponding
checkin to the trunk.
It has been acked for the trunk:
http://gcc.gnu.org/ml/gcc-patches/2013-07/msg00111.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/60847] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
2014-04-15 16:05 ` [Bug c/60847] " spatel at rotateright dot com
2014-04-15 16:13 ` [Bug target/60847] " jakub at gcc dot gnu.org
@ 2014-04-15 16:17 ` spatel at rotateright dot com
2014-04-15 16:18 ` [Bug target/60847] [4.9/4.10 Regression] " jakub at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: spatel at rotateright dot com @ 2014-04-15 16:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
Sanjay Patel <spatel at rotateright dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|target |c
--- Comment #3 from Sanjay Patel <spatel at rotateright dot com> ---
Here's the evidence of the extra leading underscore being the cause of the bug:
$ cat bmi.c
#include <x86intrin.h>
int foo(int a) { return __blsmsk_u32(a); }
int foo2(int a) { return __blsr_u32(a); }
$ gcc -O1 bmi.c -mbmi -S -o -
.text
.globl _foo
_foo:
LFB2449:
blsmsk %edi, %eax
ret
LFE2449:
.globl _foo2
_foo2:
LFB2450:
blsr %edi, %eax
ret
Thanks to Craig Topper for noticing the underscore problem. Corresponding bug
in LLVM where this was first noted is here:
http://llvm.org/bugs/show_bug.cgi?id=19431
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/60847] [4.9/4.10 Regression] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
` (2 preceding siblings ...)
2014-04-15 16:17 ` [Bug c/60847] " spatel at rotateright dot com
@ 2014-04-15 16:18 ` jakub at gcc dot gnu.org
2014-04-17 10:03 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-15 16:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-04-15
Component|c |target
Target Milestone|--- |4.9.0
Summary|x86 BMI intrinsics not |[4.9/4.10 Regression] x86
|recognized |BMI intrinsics not
| |recognized
Ever confirmed|0 |1
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
As the aliases have been added to 4.8 branch only, this makes it a regression
from 4.8.x.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/60847] [4.9/4.10 Regression] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
` (3 preceding siblings ...)
2014-04-15 16:18 ` [Bug target/60847] [4.9/4.10 Regression] " jakub at gcc dot gnu.org
@ 2014-04-17 10:03 ` jakub at gcc dot gnu.org
2014-04-17 10:10 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-17 10:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Thu Apr 17 10:02:36 2014
New Revision: 209471
URL: http://gcc.gnu.org/viewcvs?rev=209471&root=gcc&view=rev
Log:
PR target/60847
Forward port from 4.8 branch
2013-07-19 Kirill Yukhin <kirill.yukhin@intel.com>
* config/i386/bmiintrin.h (_blsi_u32): New.
(_blsi_u64): Ditto.
(_blsr_u32): Ditto.
(_blsr_u64): Ditto.
(_blsmsk_u32): Ditto.
(_blsmsk_u64): Ditto.
(_tzcnt_u32): Ditto.
(_tzcnt_u64): Ditto.
* gcc.target/i386/bmi-1.c: Extend with new instrinsics.
Fix scan patterns.
* gcc.target/i386/bmi-2.c: Ditto.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/bmiintrin.h
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.target/i386/bmi-1.c
trunk/gcc/testsuite/gcc.target/i386/bmi-2.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/60847] [4.9/4.10 Regression] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
` (4 preceding siblings ...)
2014-04-17 10:03 ` jakub at gcc dot gnu.org
@ 2014-04-17 10:10 ` jakub at gcc dot gnu.org
2014-04-17 10:14 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-17 10:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Thu Apr 17 10:09:45 2014
New Revision: 209472
URL: http://gcc.gnu.org/viewcvs?rev=209472&root=gcc&view=rev
Log:
PR target/60847
Forward port from 4.8 branch
2013-07-19 Kirill Yukhin <kirill.yukhin@intel.com>
* config/i386/bmiintrin.h (_blsi_u32): New.
(_blsi_u64): Ditto.
(_blsr_u32): Ditto.
(_blsr_u64): Ditto.
(_blsmsk_u32): Ditto.
(_blsmsk_u64): Ditto.
(_tzcnt_u32): Ditto.
(_tzcnt_u64): Ditto.
* gcc.target/i386/bmi-1.c: Extend with new instrinsics.
Fix scan patterns.
* gcc.target/i386/bmi-2.c: Ditto.
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/config/i386/bmiintrin.h
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
branches/gcc-4_9-branch/gcc/testsuite/gcc.target/i386/bmi-1.c
branches/gcc-4_9-branch/gcc/testsuite/gcc.target/i386/bmi-2.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/60847] [4.9/4.10 Regression] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
` (5 preceding siblings ...)
2014-04-17 10:10 ` jakub at gcc dot gnu.org
@ 2014-04-17 10:14 ` jakub at gcc dot gnu.org
2014-04-30 19:45 ` spatel at rotateright dot com
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-17 10:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be fixed now.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/60847] [4.9/4.10 Regression] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
` (6 preceding siblings ...)
2014-04-17 10:14 ` jakub at gcc dot gnu.org
@ 2014-04-30 19:45 ` spatel at rotateright dot com
2014-04-30 19:49 ` jakub at gcc dot gnu.org
2014-04-30 20:06 ` spatel at rotateright dot com
9 siblings, 0 replies; 11+ messages in thread
From: spatel at rotateright dot com @ 2014-04-30 19:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
--- Comment #8 from Sanjay Patel <spatel at rotateright dot com> ---
Thanks, Jakub.
I see that the fix duplicates all of the intrinsics with a
double-leading-underscore variant. Why do we need that? AFAIK, no other x86
intrinsics have this kind of duplication.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/60847] [4.9/4.10 Regression] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
` (7 preceding siblings ...)
2014-04-30 19:45 ` spatel at rotateright dot com
@ 2014-04-30 19:49 ` jakub at gcc dot gnu.org
2014-04-30 20:06 ` spatel at rotateright dot com
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-30 19:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Sanjay Patel from comment #8)
> Thanks, Jakub.
>
> I see that the fix duplicates all of the intrinsics with a
> double-leading-underscore variant. Why do we need that? AFAIK, no other x86
> intrinsics have this kind of duplication.
That is because one kind of these intrinsics originates from AMD (support for
AMD BMI is what went into GCC first) and the other from ICC which chose to
provide different names. So, for backwards compatibility we need both sets.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/60847] [4.9/4.10 Regression] x86 BMI intrinsics not recognized
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
` (8 preceding siblings ...)
2014-04-30 19:49 ` jakub at gcc dot gnu.org
@ 2014-04-30 20:06 ` spatel at rotateright dot com
9 siblings, 0 replies; 11+ messages in thread
From: spatel at rotateright dot com @ 2014-04-30 20:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60847
--- Comment #10 from Sanjay Patel <spatel at rotateright dot com> ---
Ah - thank you for the explanation! I found the original checkin from AMD:
http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01356.html
Strangely, I can't find any documentation for those double-underscores from AMD
though.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-04-30 20:06 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-15 16:02 [Bug c/60847] New: x86 BMI intrinsics not recognized spatel at rotateright dot com
2014-04-15 16:05 ` [Bug c/60847] " spatel at rotateright dot com
2014-04-15 16:13 ` [Bug target/60847] " jakub at gcc dot gnu.org
2014-04-15 16:17 ` [Bug c/60847] " spatel at rotateright dot com
2014-04-15 16:18 ` [Bug target/60847] [4.9/4.10 Regression] " jakub at gcc dot gnu.org
2014-04-17 10:03 ` jakub at gcc dot gnu.org
2014-04-17 10:10 ` jakub at gcc dot gnu.org
2014-04-17 10:14 ` jakub at gcc dot gnu.org
2014-04-30 19:45 ` spatel at rotateright dot com
2014-04-30 19:49 ` jakub at gcc dot gnu.org
2014-04-30 20:06 ` spatel at rotateright dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).