lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


copy that, thank you~~

Roberto Ierusalimschy <roberto@inf.puc-rio.br> 于2023年1月21日周六 01:46写道:
>
> >  I found this explanation on this webpage
> > https://answerbun.com/stack-overflow/why-is-__int128_t-faster-than-long-long-on-x86-64-gcc/
> >
> > idiv r64 is 56 uops for the front-end, with latency from 41 to 95
> > cycles (from divisor to quotient, which is the relevant case here I
> > think).
> > div r64 is 33 uops for the front-end, with latency from 35 to 87
> > cycles. (for that same latency path).
> >
> > Probably DIV is faster than iDIV,
> > the DIV latency is shorter
>
> Precisely. As the comment there explains: "If integer fits as a
> non-negative int, compute an int remainder, which is faster. Otherwise,
> use an unsigned-integer remainder, which uses all bits and ensures a
> non-negative result."
>
> -- Roberto