diff options
author | Michael Kuperstein <mkuper@google.com> | 2016-09-01 17:59:24 +0000 |
---|---|---|
committer | Michael Kuperstein <mkuper@google.com> | 2016-09-01 17:59:24 +0000 |
commit | 65bc3c89ffcf7290d7a676c3100edbb3a4b584a1 (patch) | |
tree | 9e7152026f65189462eb70d15a46db501dbfe50a /llvm/lib/CodeGen | |
parent | b28fe0307f2cf7620a92cb594d04e0e6b342a78d (diff) | |
download | bcm5719-llvm-65bc3c89ffcf7290d7a676c3100edbb3a4b584a1.tar.gz bcm5719-llvm-65bc3c89ffcf7290d7a676c3100edbb3a4b584a1.zip |
[DAGCombine] Don't fold a trunc if it feeds an anyext
Legalization tends to create anyext(trunc) patterns. This should always be
combined - into either a single trunc, a single ext, or nothing if the
types match exactly. But if we happen to combine the trunc first, we may pull
the trunc away from the anyext or make it implicit (e.g. the truncate(extract)
-> extract(bitcast) fold).
To prevent this, we can avoid doing the fold, similarly to how we already handle
fpround(fpextend).
Differential Revision: https://reviews.llvm.org/D23893
llvm-svn: 280386
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index fc5501622b6..80db5ee8943 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7135,6 +7135,10 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) { return N0.getOperand(0); } + // If this is anyext(trunc), don't fold it, allow ourselves to be folded. + if (N->hasOneUse() && (N->use_begin()->getOpcode() == ISD::ANY_EXTEND)) + return SDValue(); + // Fold extract-and-trunc into a narrow extract. For example: // i64 x = EXTRACT_VECTOR_ELT(v2i64 val, i32 1) // i32 y = TRUNCATE(i64 x) |