https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67513
--- Comment #3 from Andrey Ryabinin <ryabinin.a.a at gmail dot com> ---
(In reply to Yury Gribov from comment #1)
> (In reply to Andrey Ryabinin from comment #0)
> > (shadow value is usually zero).
>
> What makes you think so? AFAIU for less-than-8-byte scalars it's always
> non-zero.
If 'a' is a pointer to an individual stack/global variable then yes, shadow
will be non-zero.
But if it's part of some array or a struct field, more likely shadow will be
zero.
So I'm not saying that we should blindly switch to non-zero test first, but it
definitely worth trying.
> I vaguely remember than Kostya did something like this in Clang
> case and it resulted in negligeable improvement.
clang (version 3.7.0 (tags/RELEASE_370/final))
tests for non-zero first:
foo: # @foo
.cfi_startproc
# BB#0:
pushq %rax
.Ltmp0:
.cfi_def_cfa_offset 16
testl %esi, %esi
je .LBB0_4
# BB#1: # %.lr.ph
movq %rdi, %rax
shrq $3, %rax
movb 2147450880(%rax), %al
testb %al, %al
jne .LBB0_2
.LBB0_3:
movl $0, (%rdi)
.LBB0_4:
popq %rax
retq
.LBB0_2:
movl %edi, %ecx
andl $7, %ecx
addl $3, %ecx
movsbl %al, %eax
cmpl %eax, %ecx
jl .LBB0_3
# BB#5:
callq __asan_report_store4
#APP
#NO_APP
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.cfi_endproc