This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] try to reduce compare of funnel shift equal 0
ClosedPublic

Authored by spatel on Apr 1 2022, 10:37 AM.

Details

Summary

fshl (or X, Y), X, C ==/!= 0 --> or (shl Y, C), X ==/!= 0
fshl X, (or X, Y), C ==/!= 0 --> or (srl Y, BW-C), X ==/!= 0

This is similar to an existing setcc-of-rotate fold, but the matching requires more checks for the more general funnel op:
https://alive2.llvm.org/ce/z/Ab2jDd

We are effectively decomposing the funnel shift into logical shifts, reassociating, and removing a shift.

This should get us the final improvements for x86-64 that were originally shown in D111530 ( https://github.com/llvm/llvm-project/issues/49541 ); x86-32 still shows some SHLD/SHRD, so the pattern is not matching there yet.

Diff Detail

Event Timeline

spatel created this revision.Apr 1 2022, 10:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 10:37 AM
spatel requested review of this revision.Apr 1 2022, 10:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2022, 10:37 AM
RKSimon accepted this revision.Apr 5 2022, 1:12 AM

LGTM - although its a shame if we can't fold foldSetCCWithRotate into this more general case.

This revision is now accepted and ready to land.Apr 5 2022, 1:12 AM
This revision was landed with ongoing or failed builds.Apr 11 2022, 4:50 AM
This revision was automatically updated to reflect the committed changes.