1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

[SelectionDAGBuilder] Hide existence of ConstantDataVector vector from visitGetElementPtr.

ConstantDataVector is a specialized verison of ConstantVector
that stores data in a packed array of bits instead of as
individual pointers to other Constants. But we really shouldn't
expose that if we can void it. And we should handle regular
ConstantVector equally well.

This removes a dyn_cast to ConstantDataVector and just calls
getSplatValue directly on a Constant* if the type is a vector.

llvm-svn: 370018
This commit is contained in:
Craig Topper 2019-08-27 06:39:50 +00:00
parent 8ad31759cc
commit c21b4abf8e

View File

@ -3826,7 +3826,7 @@ void SelectionDAGBuilder::visitGetElementPtr(const User &I) {
// Normalize Vector GEP - all scalar operands should be converted to the // Normalize Vector GEP - all scalar operands should be converted to the
// splat vector. // splat vector.
unsigned VectorWidth = I.getType()->isVectorTy() ? unsigned VectorWidth = I.getType()->isVectorTy() ?
cast<VectorType>(I.getType())->getVectorNumElements() : 0; I.getType()->getVectorNumElements() : 0;
if (VectorWidth && !N.getValueType().isVector()) { if (VectorWidth && !N.getValueType().isVector()) {
LLVMContext &Context = *DAG.getContext(); LLVMContext &Context = *DAG.getContext();
@ -3859,12 +3859,11 @@ void SelectionDAGBuilder::visitGetElementPtr(const User &I) {
// If this is a scalar constant or a splat vector of constants, // If this is a scalar constant or a splat vector of constants,
// handle it quickly. // handle it quickly.
const auto *CI = dyn_cast<ConstantInt>(Idx); const auto *C = dyn_cast<Constant>(Idx);
if (!CI && isa<ConstantDataVector>(Idx) && if (C && isa<VectorType>(C->getType()))
cast<ConstantDataVector>(Idx)->getSplatValue()) C = C->getSplatValue();
CI = cast<ConstantInt>(cast<ConstantDataVector>(Idx)->getSplatValue());
if (CI) { if (const auto *CI = dyn_cast_or_null<ConstantInt>(C)) {
if (CI->isZero()) if (CI->isZero())
continue; continue;
APInt Offs = ElementSize * CI->getValue().sextOrTrunc(IdxSize); APInt Offs = ElementSize * CI->getValue().sextOrTrunc(IdxSize);