Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 9dea2ed

Browse files
committed
Handle the undef vector types.
1 parent fcd5ff2 commit 9dea2ed

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/Target/JSBackend/JSBackend.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -1019,9 +1019,18 @@ std::string JSWriter::getConstant(const Constant* CV, AsmCast sign) {
10191019
}
10201020
return CI->getValue().toString(10, sign != ASM_UNSIGNED);
10211021
} else if (isa<UndefValue>(CV)) {
1022-
std::string S = CV->getType()->isFloatingPointTy() ? "+0" : "0"; // XXX refactor this
1023-
if (PreciseF32 && CV->getType()->isFloatTy() && !(sign & ASM_FFI_OUT)) {
1024-
S = "Math_fround(" + S + ")";
1022+
std::string S;
1023+
if (VectorType *VT = dyn_cast<VectorType>(CV->getType())) {
1024+
if (VT->getElementType()->isIntegerTy()) {
1025+
S = "SIMD.int32x4.splat(0)";
1026+
} else {
1027+
S = "SIMD.float32x4.splat(0.0)";
1028+
}
1029+
} else {
1030+
S = CV->getType()->isFloatingPointTy() ? "+0" : "0"; // XXX refactor this
1031+
if (PreciseF32 && CV->getType()->isFloatTy() && !(sign & ASM_FFI_OUT)) {
1032+
S = "Math_fround(" + S + ")";
1033+
}
10251034
}
10261035
return S;
10271036
} else if (isa<ConstantAggregateZero>(CV)) {

0 commit comments

Comments
 (0)