Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PAL and GC BitScanReverse to use __builtin_clz #89350

Merged
merged 1 commit into from
Jul 22, 2023

Conversation

AndyAyersMS
Copy link
Member

The existing PAL code was using __builtin_clzl which is intended for platforms where long is 64 bits. Instead use __builtin_clz.

The GC version had a similar issue so I've changed that too. The JIT version was already using __builtin_clz.

Fixes #89340.

The existing PAL code was using `__builtin_clzl` which is intended for platforms
where `long` is 64 bits. Instead use `__builtin_clz`.

The GC version had a similar issue so I've changed that too. The JIT version
was already using `__builtin_clz`.

Fixes dotnet#89340.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 22, 2023
@ghost ghost assigned AndyAyersMS Jul 22, 2023
@ghost
Copy link

ghost commented Jul 22, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

The existing PAL code was using __builtin_clzl which is intended for platforms where long is 64 bits. Instead use __builtin_clz.

The GC version had a similar issue so I've changed that too. The JIT version was already using __builtin_clz.

Fixes #89340.

Author: AndyAyersMS
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@AndyAyersMS
Copy link
Member Author

@jakobbotsch PTAL

cc @dotnet/jit-contrib
cc @dotnet/gc

@@ -300,12 +300,12 @@ inline uint8_t BitScanReverse(uint32_t *bitIndex, uint32_t mask)
#ifdef _MSC_VER
return _BitScanReverse((unsigned long*)bitIndex, mask);
Copy link
Member

Choose a reason for hiding this comment

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

nit: replace unsigned long with uint32_t or just unsigned to remove confusion?

@EgorBo
Copy link
Member

EgorBo commented Jul 22, 2023

Surprised it never caused any issues until now 🤔

@BruceForstall
Copy link
Member

The title of the PR says "BitScanForward" but you're actually changing "BitScanReverse"

@AndyAyersMS AndyAyersMS changed the title Update PAL and GC BitScanForward to use __builtin_clz Update PAL and GC BitScanReverse to use __builtin_clz Jul 22, 2023
@AndyAyersMS
Copy link
Member Author

The title of the PR says "BitScanForward" but you're actually changing "BitScanReverse"

Indeed. Thanks.

@AndyAyersMS
Copy link
Member Author

Errors are known.

@AndyAyersMS
Copy link
Member Author

@ghost ghost locked as resolved and limited conversation to collaborators Aug 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JIT_CountProfile32 incorrect native codegen on linux
5 participants