Commit b87db517 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[wasm-simd][scalar-lowering] Implement the rest of SimdType conversions

This fills out all possible combinations of SimdType conversions. The
implementation is not the best, it uses existing conversions instead of
creating new specific ones, but is sufficient, since we don't prioritize
performance for lowering.

I added if/else clauses to the existing implementation, so that the diff
is easier to read. I will put up a follow-up to convert it into switch
statements.

Bug: chromium:1134898,v8:10507
Change-Id: I5fcb3597882b0ea3084fdc79eb1dab9b8629044b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2453462
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70393}
parent e30c50f3
......@@ -2332,10 +2332,22 @@ Node** SimdScalarLowering::GetReplacementsWithType(Node* node, SimdType type) {
if (type == SimdType::kInt64x2) {
if (ReplacementType(node) == SimdType::kInt32x4) {
Int32ToInt64(replacements, result);
} else if (ReplacementType(node) == SimdType::kInt16x8) {
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
SmallerIntToInt32<int16_t>(replacements, to_int32);
Int32ToInt64(to_int32, result);
} else if (ReplacementType(node) == SimdType::kInt8x16) {
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
SmallerIntToInt32<int8_t>(replacements, to_int32);
Int32ToInt64(to_int32, result);
} else if (ReplacementType(node) == SimdType::kFloat64x2) {
Float64ToInt64(replacements, result);
} else if (ReplacementType(node) == SimdType::kFloat32x4) {
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Float32ToInt32(replacements, to_int32);
Int32ToInt64(to_int32, result);
} else {
UNIMPLEMENTED();
UNREACHABLE();
}
} else if (type == SimdType::kInt32x4) {
if (ReplacementType(node) == SimdType::kInt64x2) {
......@@ -2360,8 +2372,26 @@ Node** SimdScalarLowering::GetReplacementsWithType(Node* node, SimdType type) {
Node** int32_to_int64 = zone()->NewArray<Node*>(kNumLanes64);
Int32ToInt64(replacements, int32_to_int64);
Int64ToFloat64(int32_to_int64, result);
} else if (ReplacementType(node) == SimdType::kInt16x8) {
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Node** to_int64 = zone()->NewArray<Node*>(kNumLanes64);
SmallerIntToInt32<int16_t>(replacements, to_int32);
Int32ToInt64(to_int32, to_int64);
Int64ToFloat64(to_int64, result);
} else if (ReplacementType(node) == SimdType::kInt8x16) {
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Node** to_int64 = zone()->NewArray<Node*>(kNumLanes64);
SmallerIntToInt32<int8_t>(replacements, to_int32);
Int32ToInt64(to_int32, to_int64);
Int64ToFloat64(to_int64, result);
} else if (ReplacementType(node) == SimdType::kFloat32x4) {
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Node** to_int64 = zone()->NewArray<Node*>(kNumLanes64);
Float32ToInt32(replacements, to_int32);
Int32ToInt64(to_int32, to_int64);
Int64ToFloat64(to_int64, result);
} else {
UNIMPLEMENTED();
UNREACHABLE();
}
} else if (type == SimdType::kFloat32x4) {
if (ReplacementType(node) == SimdType::kFloat64x2) {
......@@ -2373,7 +2403,9 @@ Node** SimdScalarLowering::GetReplacementsWithType(Node* node, SimdType type) {
} else if (ReplacementType(node) == SimdType::kInt32x4) {
Int32ToFloat32(replacements, result);
} else if (ReplacementType(node) == SimdType::kInt16x8) {
UNIMPLEMENTED();
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
SmallerIntToInt32<int16_t>(replacements, to_int32);
Int32ToFloat32(to_int32, result);
} else if (ReplacementType(node) == SimdType::kInt8x16) {
SmallerIntToInt32<int8_t>(replacements, result);
Int32ToFloat32(result, result);
......@@ -2381,8 +2413,22 @@ Node** SimdScalarLowering::GetReplacementsWithType(Node* node, SimdType type) {
UNREACHABLE();
}
} else if (type == SimdType::kInt16x8) {
if (ReplacementType(node) == SimdType::kInt32x4) {
if (ReplacementType(node) == SimdType::kInt64x2) {
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Int64ToInt32(replacements, to_int32);
Int32ToSmallerInt<int16_t>(to_int32, result);
} else if (ReplacementType(node) == SimdType::kInt32x4) {
Int32ToSmallerInt<int16_t>(replacements, result);
} else if (ReplacementType(node) == SimdType::kInt8x16) {
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
SmallerIntToInt32<int8_t>(replacements, to_int32);
Int32ToSmallerInt<int16_t>(to_int32, result);
} else if (ReplacementType(node) == SimdType::kFloat64x2) {
Node** to_int64 = zone()->NewArray<Node*>(kNumLanes64);
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Float64ToInt64(replacements, to_int64);
Int64ToInt32(to_int64, to_int32);
Int32ToSmallerInt<int16_t>(to_int32, result);
} else if (ReplacementType(node) == SimdType::kFloat32x4) {
Node** float32_to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Float32ToInt32(replacements, float32_to_int32);
......@@ -2401,8 +2447,18 @@ Node** SimdScalarLowering::GetReplacementsWithType(Node* node, SimdType type) {
Node** int16_to_int32 = zone()->NewArray<Node*>(kNumLanes32);
SmallerIntToInt32<int16_t>(replacements, int16_to_int32);
Int32ToSmallerInt<int8_t>(int16_to_int32, result);
} else if (ReplacementType(node) == SimdType::kFloat64x2) {
Node** to_int64 = zone()->NewArray<Node*>(kNumLanes64);
Node** to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Float64ToInt64(replacements, to_int64);
Int64ToInt32(to_int64, to_int32);
Int32ToSmallerInt<int8_t>(to_int32, result);
} else if (ReplacementType(node) == SimdType::kFloat32x4) {
Node** float32_to_int32 = zone()->NewArray<Node*>(kNumLanes32);
Float32ToInt32(replacements, float32_to_int32);
Int32ToSmallerInt<int8_t>(float32_to_int32, result);
} else {
UNIMPLEMENTED();
UNREACHABLE();
}
} else {
UNREACHABLE();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment