This is an archive of the discontinued LLVM Phabricator instance.

[X86][FastISel] Handle CRC32 intrinsics
ClosedPublic

Authored by aengelke on Apr 11 2023, 8:40 AM.

Details

Summary

Some applications make heavy use of the crc32 operation (e.g., as part
of a hash function), so having a FastISel path avoids fallbacks to
SelectionDAG and improves compile times, in our case by ~1.5%.

Diff Detail

Event Timeline

aengelke created this revision.Apr 11 2023, 8:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 8:40 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
aengelke requested review of this revision.Apr 11 2023, 8:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 8:40 AM
RKSimon added inline comments.Apr 11 2023, 8:50 AM
llvm/test/CodeGen/X86/crc32-intrinsics-fast-isel-x86_64.ll
10

Please can you add a crc32-intrinsics-fast-isel-x86.ll file and put theses 32-bit tests there (with 32-bit and 64-bit targets test coverage).

aengelke updated this revision to Diff 512495.Apr 11 2023, 9:39 AM

Add i686 tests. -fast-isel-abort=3 doesn't work, so I instead check that the call wasn't missed.

RKSimon added inline comments.Apr 11 2023, 9:52 AM
llvm/test/CodeGen/X86/crc32-intrinsics-fast-isel-x86_64.ll
10

Add test_mm_crc64_u8 back with the i64 arg + trunc trick

aengelke updated this revision to Diff 512746.Apr 12 2023, 3:25 AM

Also test llvm.x86.sse42.crc32.64.8 auto-upgrade

aengelke added inline comments.Apr 12 2023, 3:27 AM
llvm/test/CodeGen/X86/crc32-intrinsics-fast-isel-x86_64.ll
10

Done, but not sure whether this is the best place to test this, llvm.x86.sse42.crc32.64.8 is just an auto-upgrade to x86_sse42_crc32_32_8.

RKSimon added inline comments.Apr 12 2023, 4:17 AM
llvm/test/CodeGen/X86/crc32-intrinsics-fast-isel-x86_64.ll
22

undo this name change

aengelke updated this revision to Diff 512830.EditedApr 12 2023, 7:46 AM

Change test name.

I personally don't like "crc64", because the instruction is named crc32, not crc64 (which is a CRC variant that uses a different polynomial than the x86 instruction).

pengfei accepted this revision.Apr 20 2023, 9:42 PM

LGTM.

This revision is now accepted and ready to land.Apr 20 2023, 9:42 PM
This revision was automatically updated to reflect the committed changes.