OSDN Git Service

[InstCombine] check one-use before applying DeMorgan nor/nand folds
authorSanjay Patel <spatel@rotateright.com>
Mon, 1 May 2017 22:25:42 +0000 (22:25 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 1 May 2017 22:25:42 +0000 (22:25 +0000)
commit5ef20bbe9cab9b64d43ced2ea90ac4f499dbe9ee
tree3098bec37c3f747aa7b63eefccaf103587ac5df0
parentce5526513bd4af0529df844e5d2bfa5a154971dc
[InstCombine] check one-use before applying DeMorgan nor/nand folds

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 may not 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.

Differential Revision: https://reviews.llvm.org/D32703

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301848 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
test/Transforms/InstCombine/demorgan.ll