Several fixes to the loongarch CRC intrinsics#2136
Merged
Conversation
GCC and LLVM both only allow using the CRC intrinsics on LA64.
Clang and GCC use char and short for the data parameter type where appropriate. The LLVM intrinsics take an i32. We should match clang and perform a cast here.
Collaborator
|
r? @sayantn rustbot has assigned @sayantn. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
Author
|
cc @heiher |
folkertdev
approved these changes
May 24, 2026
heiher
approved these changes
May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first commit makes the CRC intrinsics exclusive to 64-bit LoongArch, since they are exclusive to LA64 in Clang and GCC (see https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp#L4797).
The second commit aligns the CRC intrinsic definitions for 8 and 16-bit wide data with Clang and GCC, which both use
charandshortrather thanintfor the data parameter (see https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/larchintrin.h#L60 and https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/larchintrin.h#L152). The ARM CRC intrinsics are handled identically in stdarch already: there, the LLVM intrinsic also takes ani32but we cast fromu8oru16(https://doc.rust-lang.org/stable/src/core/stdarch/crates/core_arch/src/arm_shared/neon/generated.rs.html#63).