[Bug target/115749] Non optimal assembly for integer modulo by a constant on x86-64 CPUs
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jul 2 18:14:28 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115749
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-07-02
Depends on| |115756
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
> For the original testcase, the imul vs shift can be reduced down to just:
> ```
> unsigned long func(unsigned long x)
> {
> return x * 240;
> }
>
> ```
>
> GCC produces:
> ```
> movq %rdi, %rax
> salq $4, %rax
> subq %rdi, %rax
> salq $4, %rax
> ```
> vs:
> ```
> imulq $240, %rdi, %rax
> ```
>
> -mtune=skylake produces the imul.
I split out the tuning issue for imul to PR 115756 .
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115756
[Bug 115756] default tuning for x86_64 produces shifts for `*240`
More information about the Gcc-bugs
mailing list