On 6/30/2026 6:48 AM, Michael Matz wrote:
Hello,

On Tue, 30 Jun 2026, Richard Biener wrote:

But the cmov will still serialize this?  So the point is that the longer
non-power-of-two sequence (plus the cmov) is faster than the idiv?
Without cmov, it's always faster, yes.  We're "always" expanding idiv by
constants via granlund-montgomery-like methods at expand_divmod.  A shift
for the power of two should be faster still, and so the whole sequence
should be bounded on the non-pow2 length + cmov.  Targets where shift is
slow (avr?) may prefer the idiv, though.  So ...
And not all designs are going to serialize around the cmov.    The two RISC-V designs I'm most familiar with wouldn't.   Point being there's quite a bit of target/uarch variation here.

That's a pretty target specific thing, so again I think this is
something for RTL expansion where we evaluate division-by-constant costs
appropriately
... yeah, I agree, on gimple seems too early.
Seems like gimple->RTL expansion would be a good place.  Past that it gets much harder to recover the range information Hongtao needs.

jeff

Reply via email to