This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fix memrchr logic error that prevents folding
ClosedPublic

Authored by msebor on Jun 29 2022, 2:09 PM.

Details

Summary

The memrchr enhancement added in D123629 has a logic bug that renders it ineffective in a subset of instances. The bug is (most likely) assuming that the second argument to StringRef::find() is the number of characters to search rather than the offset to search from. The tests that were added for these instances were precommitted so they didn't fail and during review none of us noticed the expected folding wasn't done.(*)

This change corrects the mistake and enables the folding.

(*) This seems like another gotcha to keep in mind with precommitting tests, one that could be helped by having XFAIL directives for individual assertions.)

Diff Detail

Event Timeline

msebor created this revision.Jun 29 2022, 2:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 2:09 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
msebor requested review of this revision.Jun 29 2022, 2:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 2:09 PM
msebor updated this revision to Diff 441187.Jun 29 2022, 3:16 PM

Fix a copy and paste mistake in memrchr-3.ll.

nikic accepted this revision.Jun 30 2022, 12:31 AM

LGTM

This revision is now accepted and ready to land.Jun 30 2022, 12:31 AM
This revision was landed with ongoing or failed builds.Jun 30 2022, 10:36 AM
This revision was automatically updated to reflect the committed changes.