-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed as not planned
Labels
invalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bugllvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization
Description
Given the following code:
#include <utility>
bool assignment_in_expr(bool& value)
{
return value && !(value = false);
}
bool regular(bool& value)
{
bool old = value;
value = false;
return old;
}
bool exchange(bool& value)
{
return std::exchange(value, false);
}Clang (trunk) with -O3 produces (godbolt):
assignment_in_expr(bool&):
movzx eax, byte ptr [rdi]
cmp al, 1
jne .LBB0_2
mov byte ptr [rdi], 0
.LBB0_2:
ret
regular(bool&):
movzx eax, byte ptr [rdi]
mov byte ptr [rdi], 0
ret
exchange(bool&):
movzx eax, byte ptr [rdi]
mov byte ptr [rdi], 0
retFunction assignment_in_expr should produce the same assembly as the other 2 variants.
Metadata
Metadata
Assignees
Labels
invalidResolved as invalid, i.e. not a bugResolved as invalid, i.e. not a bugllvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization