Allow Builtin.bitcast to do VecNxInt1 -> IntN (#36252)

This is necessary to support the idiom for movmsk operations on x86.
This commit is contained in:
Stephen Canon
2021-03-03 16:02:09 -05:00
committed by GitHub
parent a8beb7bc94
commit 8b34d8bfb8
2 changed files with 17 additions and 0 deletions

View File

@@ -577,6 +577,15 @@ static ValueDecl *getCastOperation(ASTContext &Context, Identifier Id,
if (auto *BIT = CheckOutput->getAs<BuiltinIntegerType>())
if (BIT->isFixedWidth() && BIT->getFixedWidth() == BFT->getBitWidth())
break;
// Support VecNxInt1 -> IntN bitcast for SIMD comparison results.
if (auto *Vec = CheckInput->getAs<BuiltinVectorType>())
if (auto *BIT = CheckOutput->getAs<BuiltinIntegerType>())
if (auto *Element = Vec->getElementType()->getAs<BuiltinIntegerType>())
if (Element->getFixedWidth() == 1 &&
BIT->isFixedWidth() &&
BIT->getFixedWidth() == Vec->getNumElements())
break;
// FIXME: Implement bitcast typechecking.
llvm_unreachable("Bitcast not supported yet!");