[X86] Guard against leaving a dangling node in combineTruncateWithSat.
authorCraig Topper <craig.topper@intel.com>
Thu, 10 Oct 2019 21:46:52 +0000 (21:46 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 10 Oct 2019 21:46:52 +0000 (21:46 +0000)
commit4ee7f8365f90cb21aa0afed0754cb13493e09e7d
treea1e9ee46931f9f1a3563af47f5b67c492881f3a9
parenta0df8b72f222ec66b268eec619694eed46b8d016
[X86] Guard against leaving a dangling node in combineTruncateWithSat.

When handling the packus pattern for i32->i8 we do a two step
process using a packss to i16 followed by a packus to i8. If the
final i8 step is a type with less than 64-bits the packus step
will return SDValue(), but the i32->i16 step might have succeeded.
This leaves the nodes from the middle step dangling.

Guard against this by pre-checking that the number of elements is
at least 8 before doing the middle step.

With that check in place this should mean the only other
case the middle step itself can fail is when SSE2 is disabled. So
add an early SSE2 check then just assert that neither the middle
or final step ever fail.

llvm-svn: 374460
llvm/lib/Target/X86/X86ISelLowering.cpp