Re: [x86_64 PATCH]: Improvement to signed division of integer constant.

2021-07-08 Thread Uros Bizjak via Gcc-patches
On Thu, Jul 8, 2021 at 10:25 AM Roger Sayle wrote: > > > This patch tweaks the way GCC handles 32-bit integer division on > x86_64, when the numerator is constant. Currently the function > > int foo (int x) { > return 100/x; > } > > generates the code: > foo:movl$100, %eax > clt

Re: [x86_64 PATCH]: Improvement to signed division of integer constant.

2021-07-08 Thread Alexander Monakov via Gcc-patches
On Thu, 8 Jul 2021, Richard Biener via Gcc-patches wrote: > You made me lookup idiv and I figured we're not optimally > handling > > int foo (long x, int y) > { > return x / y; > } > > by using a 32:32 / 32 bit divide. combine manages to > see enough to eventually do this though. We cannot d

Re: [x86_64 PATCH]: Improvement to signed division of integer constant.

2021-07-08 Thread Richard Biener via Gcc-patches
On Thu, Jul 8, 2021 at 10:25 AM Roger Sayle wrote: > > > This patch tweaks the way GCC handles 32-bit integer division on > x86_64, when the numerator is constant. Currently the function > > int foo (int x) { > return 100/x; > } > > generates the code: > foo:movl$100, %eax > clt

[x86_64 PATCH]: Improvement to signed division of integer constant.

2021-07-08 Thread Roger Sayle
This patch tweaks the way GCC handles 32-bit integer division on x86_64, when the numerator is constant. Currently the function int foo (int x) { return 100/x; } generates the code: foo:movl$100, %eax cltd idivl %edi ret where the sign-extension instruction