[DAGCombiner] Fix a crash caused by a missing check for legal type when trying to...
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Sun, 13 Jul 2014 21:02:14 +0000 (21:02 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Sun, 13 Jul 2014 21:02:14 +0000 (21:02 +0000)
commit67d8b2e2b0174783b3d6ba4737978c190a4c0414
tree9ac304c3fa8378ae17ff39f3f915e418e31dbb56
parentc7c3cb1f4e83f4599fd3bc9dd3e1aca652b8fc59
[DAGCombiner] Fix a crash caused by a missing check for legal type when trying to fold shuffles.

Verify that DAGCombiner does not crash when trying to fold a pair of shuffles
according to rule (added at r212539):
  (shuffle (shuffle A, Undef, M0), Undef, M1) -> (shuffle A, Undef, M2)

The DAGCombiner avoids folding shuffles if the resulting shuffle dag node
is not legal for the target. That means, the resulting shuffle must have
legal type and legal mask.

Before, the DAGCombiner only called method
'TargetLowering::isShuffleMaskLegal' to check if it was "safe" to fold according
to the above-mentioned rule. However, this caused a crash in the x86 backend
since method 'isShuffleMaskLegal' always expects to be called on a
legal vector type.

llvm-svn: 212915
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/shuffle-combine-crash.ll [new file with mode: 0644]