This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] check one-use before applying DeMorgan nor/nand folds
ClosedPublic

Authored by spatel on May 1 2017, 10:08 AM.

Details

Summary

Splitting this off from D32665 to make sure I've thought it about correctly.

If we have:
~(~X & Y), it only makes sense to transform it to (X | ~Y) when we do not need the intermediate (~X & Y) value. In that case, we would need an extra instruction to generate ~Y + 'or' (as shown in the test changes).

It's ok if we have multiple uses of ~X or Y, however. In those cases, we won't reduce the instruction count or critical path, but we might improve throughput because we can generate ~X and ~Y in parallel. Whether that actually makes perf sense or not for a target is something we can't answer in IR.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.May 1 2017, 10:08 AM
efriedma accepted this revision.May 1 2017, 11:56 AM

LGTM.

This revision is now accepted and ready to land.May 1 2017, 11:56 AM
This revision was automatically updated to reflect the committed changes.