[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why do you want to use“cast_int“ to force “ui” to int
- From: game frog <froggame505384662@...>
- Date: Sat, 21 Jan 2023 22:08:48 +0800
So the reason for writing this is because signed is faster than unsigned ~~
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