[wasm-simd][scalar-lowering] Fix i64 to i32 replacements

Since we are converting Int64x2 to Int32x4, we should be truncating
the nodes, not sign-extending.

Bug: v8:10507
Change-Id: I09dabdcaaa378842ffb4da5505199c188b5101f1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2404751
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69831}
This commit is contained in:
Ng Zhi An 2020-09-10 15:46:03 -07:00 committed by Commit Bot
parent 413ebe59a0
commit 9e81be7423

View File

@ -2112,15 +2112,14 @@ void SimdScalarLowering::Float32ToInt32(Node** replacements, Node** result) {
void SimdScalarLowering::Int64ToInt32(Node** replacements, Node** result) {
const int num_ints = sizeof(int64_t) / sizeof(int32_t);
const int bit_size = sizeof(int32_t) * 8;
const Operator* sign_extend = machine()->SignExtendWord32ToInt64();
const Operator* truncate = machine()->TruncateInt64ToInt32();
for (int i = 0; i < kNumLanes64; i++) {
if (replacements[i] != nullptr) {
for (int j = 0; j < num_ints; j++) {
result[num_ints * i + j] = graph()->NewNode(
sign_extend,
graph()->NewNode(machine()->Word64Sar(), replacements[i],
mcgraph_->Int32Constant(j * bit_size)));
truncate, graph()->NewNode(machine()->Word64Sar(), replacements[i],
mcgraph_->Int32Constant(j * bit_size)));
}
} else {
for (int j = 0; j < num_ints; j++) {