This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/49244] __sync or __atomic builtins will not emit 'lock bts/btr/btc'
- From: "dhowells at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 03 May 2016 07:22:58 +0000
- Subject: [Bug target/49244] __sync or __atomic builtins will not emit 'lock bts/btr/btc'
- Auto-submitted: auto-generated
- References: <bug-49244-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49244
--- Comment #18 from dhowells at redhat dot com <dhowells at redhat dot com> ---
(In reply to Paolo Bonzini from comment #16)
> > This also suggests there's an error in the current x86_64 kernel implementation
> > as the kernel bitops are supposed to operate on machine word-size locations, so
> > it should be using BTSQ not BTSL
>
> Why? Since bts adjust the memory address according to the bit number, btsl
> and btsq are entirely the same instruction.
Actually, no. BTSL takes a 32-bit bit number, whereas BTSQ takes a 64-bit bit
number if I read the manual correctly.
So, since test_and_set_bit() in the kernel takes a long bit number, BTSQ is the
right thing to use.
In practice, I don't imagine this is likely to be a real problem. I don't
envision it as being likely that we will ever have a contiguous bitmap with
>=2^31 bits in it.