[Bug tree-optimization/85610] New: Unable to optimize away mov followed by compare into a cmpb in case of atomic_load
hiraditya at msn dot com
gcc-bugzilla@gcc.gnu.org
Wed May 2 14:22:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85610
Bug ID: 85610
Summary: Unable to optimize away mov followed by compare into a
cmpb in case of atomic_load
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: hiraditya at msn dot com
Target Milestone: ---
$ cat test.cpp
#include <atomic>
std::atomic<bool> flag_atomic{false};
extern void f1();
extern void f2();
void foo() {
bool b = flag_atomic.load(std::memory_order_relaxed);
if (b == false) {
f1();
} else {
f2();
}
}
$ g++-7 -O3 -S -o - test.cpp -std=c++14
__Z3foov:
LFB342:
movzbl _flag_atomic(%rip), %eax
testb %al, %al
je L4
jmp __Z2f2v
.align 4,0x90
L4:
jmp __Z2f1v
We could just use `cmpb $0, _flag_atomic(%rip)` and avoid a register in this
case. When _flag_atomic is a scalar boolean global variable, that's what
happens.
More information about the Gcc-bugs
mailing list