https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127900
Bug ID: 127900
Summary: [X86_64] Missed generating mulx when bmi2 is available
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: vekumar at gcc dot gnu.org
Target Milestone: ---
GCC in some cases misses to generate mulx in the presence of mul.
This is inspired from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127452#c4
and opened a fresh PR for the issue alone.
typedef unsigned long long u64;
u64
mulh (u64 a, u64 b)
{
return ((unsigned __int128) a * b) >> 64;
}
gcc -O2 -march=x86-64-v2 -mbmi2
"mulh":
mov rax, rdi
mul rsi
mov rax, rdx
ret
ref: https://godbolt.org/z/oja4vvde7