Open zmodem opened 10 years ago
For
unsigned f(unsigned *addr) { return __sync_fetch_and_or(addr, 1 << 7) & (1 << 7); }
We currently generate:
f: movl (%rdi), %eax .LBB0_1: movl $128, %ecx orl %eax, %ecx lock cmpxchgl %ecx, (%rdi) jne .LBB0_1 andl $128, %eax retq
It would be cool if we could recognize that the read-modify-write we're doing here is actually bit-test-and-set, which can be done with the bts instruction.
mentioned in issue llvm/llvm-bugzilla-archive#32566
Bug llvm/llvm-bugzilla-archive#32566 has been marked as a duplicate of this bug.
Extended Description
For
unsigned f(unsigned *addr) { return __sync_fetch_and_or(addr, 1 << 7) & (1 << 7); }
We currently generate:
f: movl (%rdi), %eax .LBB0_1: movl $128, %ecx orl %eax, %ecx lock cmpxchgl %ecx, (%rdi) jne .LBB0_1 andl $128, %eax retq
It would be cool if we could recognize that the read-modify-write we're doing here is actually bit-test-and-set, which can be done with the bts instruction.