[DAG] Further improve the logic in DAGCombiner that folds a pair of shuffles into...
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Thu, 10 Jul 2014 18:04:55 +0000 (18:04 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Thu, 10 Jul 2014 18:04:55 +0000 (18:04 +0000)
commitb2921c7ca00afe7d1dd9194a60fb6460e94aa4a9
treec6826a402a6330cdd82c0ab0d26ace14fa47b245
parent7cc27649a68170c6da3cecbde94e8a14dd56346e
[DAG] Further improve the logic in DAGCombiner that folds a pair of shuffles into a single shuffle if the resulting mask is legal.

This patch teaches the DAGCombiner how to fold shuffles according to the
following new rules:
  1. shuffle(shuffle(x, y), undef) -> x
  2. shuffle(shuffle(x, y), undef) -> y
  3. shuffle(shuffle(x, y), undef) -> shuffle(x, undef)
  4. shuffle(shuffle(x, y), undef) -> shuffle(y, undef)

The backend avoids to combine shuffles according to rules 3. and 4. if
the resulting shuffle does not have a legal mask. This is to avoid introducing
illegal shuffles that are potentially expanded into a sub-optimal sequence of
target specific dag nodes during vector legalization.

Added test case combine-vec-shuffle-2.ll to verify that we correctly triggers
the new rules when combining shuffles.

llvm-svn: 212748
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/combine-vec-shuffle-2.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/widen_shuffle-1.ll