diff options
author | Simon Tatham <simon.tatham@arm.com> | 2020-02-17 09:11:35 +0000 |
---|---|---|
committer | Simon Tatham <simon.tatham@arm.com> | 2020-02-17 09:30:45 +0000 |
commit | 377b0e2b06f90c4edbd320cf9d833af5979f8f5d (patch) | |
tree | e2d193bd3025f8f48ab49fb7c97386c5e4b9d9d4 /llvm/utils/TableGen/CodeGenDAGPatterns.cpp | |
parent | 516ba158b6890bbcca71527ae0719de151b9de5f (diff) | |
download | llvm-377b0e2b06f90c4edbd320cf9d833af5979f8f5d.zip llvm-377b0e2b06f90c4edbd320cf9d833af5979f8f5d.tar.gz llvm-377b0e2b06f90c4edbd320cf9d833af5979f8f5d.tar.bz2 |
[TableGen] Don't elide bitconverts in PatFrag fragments.
Summary:
In the DAG pattern backend, `SimplifyTree` simplifies a pattern by
removing bitconverts between two identical types. But that function is
also run on the fragments list in instances of `PatFrags`, in which
the types haven't been specified yet. So the input and output of the
bitconvert always evaluate to the empty set of types, which makes them
compare equal. So the test always passes, and bitconverts are
unconditionally removed from the PatFrag RHS.
Fixed by spotting the empty type set and using it to inhibit the
optimization.
Reviewers: nhaehnle, hfinkel
Reviewed By: nhaehnle
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74627
Diffstat (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.cpp')
-rw-r--r-- | llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 703cd51..0ea90d7 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -2918,8 +2918,15 @@ static bool SimplifyTree(TreePatternNodePtr &N) { // If we have a bitconvert with a resolved type and if the source and // destination types are the same, then the bitconvert is useless, remove it. + // + // We make an exception if the types are completely empty. This can come up + // when the pattern being simplified is in the Fragments list of a PatFrags, + // so that the operand is just an untyped "node". In that situation we leave + // bitconverts unsimplified, and simplify them later once the fragment is + // expanded into its true context. if (N->getOperator()->getName() == "bitconvert" && N->getExtType(0).isValueTypeByHwMode(false) && + !N->getExtType(0).empty() && N->getExtType(0) == N->getChild(0)->getExtType(0) && N->getName().empty()) { N = N->getChildShared(0); |