This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Add simple folds for SSHLSAT/USHLSAT
ClosedPublic

Authored by bjope on Jan 31 2022, 5:42 AM.

Details

Summary

Do "simplifyShift" and "FoldConstantArithmetic" folds for the SSHLSAT
and USHLSAT DAG nodes.

This for example include folds such as:

(shlsat 0, x) -> 0
(shlsat x, 0) -> x
(shlsat c1, c2) -> c3

Diff Detail

Event Timeline

bjope created this revision.Jan 31 2022, 5:42 AM
bjope requested review of this revision.Jan 31 2022, 5:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 31 2022, 5:42 AM
RKSimon added inline comments.Jan 31 2022, 9:37 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
9356

Do you have any test coverage for undef/poison/outofrangeamt operands - that's mainly what simplifyShift handles?

bjope updated this revision to Diff 404650.Jan 31 2022, 11:52 AM

Added test cases for undef/poison/out-of-bounds-shamt:

(shlsat undef/poison, x) -> 0
(shlsat x, undef/poison) -> undef
(shlsat x, too_large_shamt) -> undef
RKSimon accepted this revision.Jan 31 2022, 1:41 PM

LGTM - please can you pre-commit the tests and then rebase so that the patch commit shows the codegen diffs

This revision is now accepted and ready to land.Jan 31 2022, 1:41 PM
This revision was landed with ongoing or failed builds.Feb 1 2022, 1:52 AM
This revision was automatically updated to reflect the committed changes.
bjope marked an inline comment as done.Feb 1 2022, 1:53 AM

LGTM - please can you pre-commit the tests and then rebase so that the patch commit shows the codegen diffs

Ok, thanks! I did pre-committ the tests before landing.