[x86] Fix a failure to select with AVX-512 when the type legalizer
authorChandler Carruth <chandlerc@gmail.com>
Thu, 11 May 2017 10:52:16 +0000 (10:52 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 11 May 2017 10:52:16 +0000 (10:52 +0000)
commit97500a9918d7de5282bc3739a2a907d8e0f50562
tree0ef6e384648c5b911d10d4b530a6912409ffe633
parenta4a13a0da08ad2f985f7f7f5dc3cf1b998d4fb3e
[x86] Fix a failure to select with AVX-512 when the type legalizer
manages to form a VSELECT with a non-i1 element type condition. Those
are technically allowed in SDAG (at least, the generic type legalization
logic will form them and I wouldn't want to try to audit everything te
preclude forming them) so we need to be able to lower them.

This isn't too hard to implement. We mark VSELECT as custom so we get
a chance in C++, add a fast path for i1 conditions to get directly
handled by the patterns, and a fallback when we need to manually force
the condition to be an i1 that uses the vptestm instruction to turn
a non-mask into a mask.

This, unsurprisingly, generates awful code. But it at least doesn't
crash. This was actually impacting open source packages built with LLVM
for AVX-512 in the wild, so quickly landing a patch that at least stops
the immediate bleeding.

I think I've found where to fix the codegen quality issue, but less
confident of that change so separating it out from the thing that
doesn't change the result of any existing test case but causes mine to
not crash.

llvm-svn: 302785
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx512-vselect.ll [new file with mode: 0644]