https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98865
Bug ID: 98865
Summary: Missed transform of (a >> 63) * b
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
Target Milestone: ---
unsigned long foo (unsigned long a, unsigned long b)
{
return (a >> 63) * b;
}
generates
foo:
.LFB0:
.cfi_startproc
shrq $63, %rdi
movq %rdi, %rax
imulq %rsi, %rax
ret
but we can do (like llvm):
foo: # @foo
.cfi_startproc
# %bb.0:
movq %rdi, %rax
sarq $63, %rax
andq %rsi, %rax
retq