This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] enable binop identity constant folds for shifts
ClosedPublic

Authored by RKSimon on Mar 19 2022, 8:22 AM.

Details

Summary

Add shl/srl/sra to the list of ops that we canonicalize with a select to expose an identity merge

Diff Detail

Event Timeline

RKSimon created this revision.Mar 19 2022, 8:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2022, 8:22 AM
RKSimon requested review of this revision.Mar 19 2022, 8:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2022, 8:22 AM
pengfei added inline comments.Mar 19 2022, 8:29 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2168

Can it apply to ROTL/ROTR ?

RKSimon added inline comments.Mar 19 2022, 8:59 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2168

Yes, we'd have to account for the implicit modulo though.

There's plenty of other ops we could attempt with this as well, including some non-binops (funnel shifts and fma for instance) - I'm also wondering what target binops will need to be supported.

LuoYuanke accepted this revision.Mar 19 2022, 7:23 PM

LGTM, thanks.

This revision is now accepted and ready to land.Mar 19 2022, 7:23 PM
This revision was landed with ongoing or failed builds.Mar 21 2022, 6:03 AM
This revision was automatically updated to reflect the committed changes.