Re: [x86 PATCH]: Additional peephole2 to use lea in round-up integer division.

2024-06-30 Thread Uros Bizjak
On Sun, Jun 30, 2024 at 9:09 PM Roger Sayle wrote: > > > Hi Uros, > > On Sat, Jun 29, 2024 at 6:21 PM Roger Sayle > > wrote: > > > A common idiom for implementing an integer division that rounds > > > upwards is to write (x + y - 1) / y. Conveniently on x86, the two > > > additions to form the n

RE: [x86 PATCH]: Additional peephole2 to use lea in round-up integer division.

2024-06-30 Thread Roger Sayle
Hi Uros, > On Sat, Jun 29, 2024 at 6:21 PM Roger Sayle > wrote: > > A common idiom for implementing an integer division that rounds > > upwards is to write (x + y - 1) / y. Conveniently on x86, the two > > additions to form the numerator can be performed by a single lea > > instruction, and ind

Re: [x86 PATCH]: Additional peephole2 to use lea in round-up integer division.

2024-06-30 Thread Uros Bizjak
On Sat, Jun 29, 2024 at 6:21 PM Roger Sayle wrote: > > > A common idiom for implementing an integer division that rounds upwards is > to write (x + y - 1) / y. Conveniently on x86, the two additions to form > the numerator can be performed by a single lea instruction, and indeed gcc > currently g

[x86 PATCH]: Additional peephole2 to use lea in round-up integer division.

2024-06-29 Thread Roger Sayle
A common idiom for implementing an integer division that rounds upwards is to write (x + y - 1) / y. Conveniently on x86, the two additions to form the numerator can be performed by a single lea instruction, and indeed gcc currently generates a lea when x and y both registers. int foo(int x, int