This is an archive of the discontinued LLVM Phabricator instance.

[WIP] [Intrinsics] Introduce memcmp intrinsics.
Changes PlannedPublic

Authored by dmakogon on Sep 9 2021, 5:51 AM.

Details

Summary

This is currently WIP and there is no LangRef entry for the intrinsic.
This intrinsic can be used to compare two block of memory and returns whether they are equal or not.
Please review the patch and express your concerns about this.

This patch depends on another one which changes the memory intrinsics class hierarchy.

Diff Detail

Event Timeline

dmakogon created this revision.Sep 9 2021, 5:51 AM
dmakogon requested review of this revision.Sep 9 2021, 5:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2021, 5:51 AM
This comment was removed by mkazantsev.

Since this is a change to LangRef, please, post the proposal to llvm-dev.

In general this intrinsic looks reasonable and fits well with other libc intrinsics. One thing to think about is how to handle this intrinsic in the optimizer. Looks like there are plenty of places where the optimizer knows to recognize memcmp as a known libc function. For example, there are quite a few simplifications in LibCallSimplifier::optimizeMemCmp. Grep by "LibFunc_memcmp" to see other places. Do we want to canonicalize memcmp calls to the new intrinsic and teach every place to handle the intrinsic? This would make sense because we would also handle the new element atomic memcmp version this way.

I also notice that the new memcmp intrinsic returns i1, which is different from libc memcmp. libc memcmp returns and int indicating which of the sides was greater. Looks like, the new intrinsic matches with bcmp semantic.

dmakogon planned changes to this revision.Oct 12 2021, 11:11 PM
lebedev.ri resigned from this revision.Jan 12 2023, 4:49 PM

This review seems to be stuck/dead, consider abandoning if no longer relevant.

Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 4:49 PM
Herald added a subscriber: StephenFan. · View Herald Transcript