[DAGCombine] Don't fold a trunc if it feeds an anyext
authorMichael Kuperstein <mkuper@google.com>
Thu, 1 Sep 2016 17:59:24 +0000 (17:59 +0000)
committerMichael Kuperstein <mkuper@google.com>
Thu, 1 Sep 2016 17:59:24 +0000 (17:59 +0000)
commit65bc3c89ffcf7290d7a676c3100edbb3a4b584a1
tree9e7152026f65189462eb70d15a46db501dbfe50a
parentb28fe0307f2cf7620a92cb594d04e0e6b342a78d
[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
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/2011-10-21-widen-cmp.ll
llvm/test/CodeGen/X86/mem-intrin-base-reg.ll