New Decimal.Remainder implementation by pentp · Pull Request #20305 · dotnet/coreclr (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jit doesn't do anything like this today.

Combining tests like this -- where the expressions are side effect free and low cost -- can often pay off. But it is not always a win. It depends on the predictability of the branches and what else is going on in the neighborhood.

For instance if d2.High is usually nonzero, perf might get a bit worse by combining the checks this way.

But I'm guessing that for decimals the high part is likely to be zero and this is a pretty safe win.