[InstCombine][X86] getNegativeIsTrueBoolVec - use ConstantExpr evaluators. NFCI.

Don't do this manually, we can just use the ConstantExpr evaluators to do it more tidily for us.
This commit is contained in:
Simon Pilgrim 2020-09-12 13:51:25 +01:00
parent c437446d90
commit 50ee0b99ec
1 changed files with 6 additions and 13 deletions

View File

@ -24,19 +24,12 @@ using namespace llvm;
/// Return a constant boolean vector that has true elements in all positions /// Return a constant boolean vector that has true elements in all positions
/// where the input constant data vector has an element with the sign bit set. /// where the input constant data vector has an element with the sign bit set.
static Constant *getNegativeIsTrueBoolVec(ConstantDataVector *V) { static Constant *getNegativeIsTrueBoolVec(Constant *V) {
SmallVector<Constant *, 32> BoolVec; VectorType *IntTy = VectorType::getInteger(cast<VectorType>(V->getType()));
IntegerType *BoolTy = Type::getInt1Ty(V->getContext()); V = ConstantExpr::getBitCast(V, IntTy);
for (unsigned I = 0, E = V->getNumElements(); I != E; ++I) { V = ConstantExpr::getICmp(CmpInst::ICMP_SGT, Constant::getNullValue(IntTy),
Constant *Elt = V->getElementAsConstant(I); V);
assert((isa<ConstantInt>(Elt) || isa<ConstantFP>(Elt)) && return V;
"Unexpected constant data vector element type");
bool Sign = V->getElementType()->isIntegerTy()
? cast<ConstantInt>(Elt)->isNegative()
: cast<ConstantFP>(Elt)->isNegative();
BoolVec.push_back(ConstantInt::get(BoolTy, Sign));
}
return ConstantVector::get(BoolVec);
} }
// TODO: If the x86 backend knew how to convert a bool vector mask back to an // TODO: If the x86 backend knew how to convert a bool vector mask back to an