Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Removes unnecessary shift count masking #11594

Merged
merged 1 commit into from May 19, 2017

Commits on May 14, 2017

  1. Removes unnecessary shift count masking

    The C# compiler translates code like `x << y` to `x << (y & 31)` because the behavior of IL shift operations is unspecified if the shift count is greater than or equal to the bit width of the shifted value. However, x86/x64 shift instructions do mask the shift count so `& 31` is redundant.
    
    It's also possible that developers also mask the shift count, not knowing that the C# language specification guarantees masking. In that case we end up with 2 `and x, 31` instructions.
    mikedn committed May 14, 2017
    Copy the full SHA
    ea6582e View commit details
    Browse the repository at this point in the history