This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/36503] x86 can use x >> -y for x >> 32-y
- From: "bonzini at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Nov 2009 09:21:54 -0000
- Subject: [Bug target/36503] x86 can use x >> -y for x >> 32-y
- References: <bug-36503-10175@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from bonzini at gnu dot org 2009-11-07 09:21 -------
bt with a memory object and a register index will _not_ truncate the argument:
static int btm(int *a, int b) {
asm ("btl %2, %1; movl $0, %0; setc %b0" : "=r" (b) : "m" (*a), "0" (b));
return b;
}
static int btr(int a, int b) {
asm ("btl %2, %1; movl $0, %0; setc %b0" : "=r" (b) : "r" (a), "0" (b));
return b;
}
#define btmi(a, b) ({ int __x; \
asm ("btl %2, %1; movl $0, %0; setc %b0" : "=r" (__x) : "m" (*a), "i" (b)); \
__x; \
})
int main () {
int y[3] = { 0x5, 0, 0x5 };
printf ("bt %%reg, %%reg: %d %d %d\n", btr(5, 0), btr(5, 32), btr(5, 64));
printf ("bt $bit, (mem): %d %d %d\n", btmi(y, 0), btmi(y, 32), btmi(y, 64));
printf ("bt %%reg, (mem): %d %d %d\n", btm(y, 0), btm(y, 32), btm(y, 64));
}
>> bt %reg, %reg: 1 1 1
>> bt $val, (mem): 1 1 1
>> bt %reg, (mem): 1 0 1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36503