Hello,

On Tue, 30 Jun 2026, Jeffrey Law wrote:

> > 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.

Yep, expand_divmod (well, a new subroutine I guess, it's convoluted enough 
already :) ).  Could even generate both sequences, make the target cost 
them and select the best.


Ciao,
Michael.

Reply via email to