This is an archive of the discontinued LLVM Phabricator instance.

[X86] Make `(shift X (xor/sub N-1, Y))` -> `(shift X, (not Y))` check for one use.
ClosedPublic

Authored by goldstein.w.n on Feb 28 2023, 10:09 AM.

Details

Summary

(xor/sub N-1, Y) -> (not Y) is minorly preferable (especially for
(sub N-1, Y) where it saves an instruction), but isn't worth
potentially creating an extra instruction for.

So, only do the transformation if (xor/sub N-1, Y) has one use.

Diff Detail

Event Timeline

goldstein.w.n created this revision.Feb 28 2023, 10:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2023, 10:09 AM
goldstein.w.n requested review of this revision.Feb 28 2023, 10:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2023, 10:09 AM
RKSimon accepted this revision.Feb 28 2023, 10:31 AM
RKSimon added inline comments.
llvm/test/CodeGen/X86/pr61038.ll
1–2

You might be able to get away with a common CHECK-X64-BMI2 to replace the SKX and V4 prefixes

This revision is now accepted and ready to land.Feb 28 2023, 10:31 AM
goldstein.w.n marked an inline comment as done.Feb 28 2023, 1:19 PM

Fix common prefix

This revision was landed with ongoing or failed builds.Feb 28 2023, 9:25 PM
This revision was automatically updated to reflect the committed changes.