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

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


Ciao,
Michael.

P.S: "always" in quotes because strictly speaking there are cases where we 
don't, e.g. when the modes are too wide and the divisor too wrong to 
produce the then required double-width multiplication.

Reply via email to