Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions llvm/lib/ExecutionEngine/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,25 +934,27 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
const ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(C);
const ConstantVector *CV = dyn_cast<ConstantVector>(C);
const ConstantAggregateZero *CAZ = dyn_cast<ConstantAggregateZero>(C);
const ConstantInt *CI = dyn_cast<ConstantInt>(C);
const ConstantFP *CFP = dyn_cast<ConstantFP>(C);

if (CDV) {
elemNum = CDV->getNumElements();
ElemTy = CDV->getElementType();
} else if (CV || CAZ) {
} else if (CV || CAZ || CI || CFP) {
auto *VTy = cast<FixedVectorType>(C->getType());
elemNum = VTy->getNumElements();
ElemTy = VTy->getElementType();
} else {
llvm_unreachable("Unknown constant vector type!");
llvm_unreachable("Unknown constant vector type!");
}

Result.AggregateVal.resize(elemNum);
// Check if vector holds floats.
if(ElemTy->isFloatTy()) {
if (CAZ) {
GenericValue floatZero;
floatZero.FloatVal = 0.f;
llvm::fill(Result.AggregateVal, floatZero);
if (CAZ || CFP) {
GenericValue floatVal;
floatVal.FloatVal = CAZ ? 0.f : CFP->getValueAPF().convertToFloat();
llvm::fill(Result.AggregateVal, floatVal);
break;
}
if(CV) {
Expand All @@ -970,10 +972,10 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
}
// Check if vector holds doubles.
if (ElemTy->isDoubleTy()) {
if (CAZ) {
GenericValue doubleZero;
doubleZero.DoubleVal = 0.0;
llvm::fill(Result.AggregateVal, doubleZero);
if (CAZ || CFP) {
GenericValue doubleVal;
doubleVal.DoubleVal = CAZ ? 0.0 : CFP->getValueAPF().convertToDouble();
llvm::fill(Result.AggregateVal, doubleVal);
break;
}
if(CV) {
Expand All @@ -991,10 +993,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
}
// Check if vector holds integers.
if (ElemTy->isIntegerTy()) {
if (CAZ) {
GenericValue intZero;
intZero.IntVal = APInt(ElemTy->getScalarSizeInBits(), 0ull);
llvm::fill(Result.AggregateVal, intZero);
if (CAZ || CI) {
GenericValue intVal;
intVal.IntVal =
CAZ ? APInt(ElemTy->getScalarSizeInBits(), 0ull) : CI->getValue();
llvm::fill(Result.AggregateVal, intVal);
break;
}
if(CV) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: %lli -jit-kind=mcjit -force-interpreter=true %s > /dev/null
; RUN: %lli -jit-kind=mcjit -force-interpreter=true -use-constant-int-for-fixed-length-splat -use-constant-fp-for-fixed-length-splat %s > /dev/null

define i32 @main() {
%v0 = insertelement <2 x i8> zeroinitializer, i8 1, i32 1
Expand Down Expand Up @@ -37,5 +38,7 @@ define i32 @main() {
%v28 = insertelement <8 x double> zeroinitializer, double 4.0, i32 4
%v29 = insertelement <16 x double> zeroinitializer, double 5.0, i32 7

%v30 = insertelement <16 x i64> splat(i64 1), i64 5, i32 7
%v31 = insertelement <16 x double> splat(double 1.0), double 5.0, i32 7
ret i32 0
}