[wasm-simd][scalar-lowering] Add regression test

This adds a regression test for a bug in lowering load transforms.
This test will fail if 0efa3fd97e is
reverted.

Bug: chromium:1124885
Change-Id: I31b714d4565c4fff730c1274af8059031cb1e1b5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2610508
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71919}
This commit is contained in:
Zhi An Ng 2021-01-05 09:05:56 +00:00 committed by Commit Bot
parent 8b33c87239
commit 76e10856c7

View File

@ -0,0 +1,47 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --experimental-wasm-simd
// This exercises an bug in scalar-lowering for load transforms. In
// particular, if the index input to v128.load32_splat was a extract_lane, the
// input wasn't correctly lowered. This caused the extract_lane node to stick
// around until code-generator, where we hit a mismatch in the register types.
load('test/mjsunit/wasm/wasm-module-builder.js');
(function() {
const builder = new WasmModuleBuilder();
builder.addMemory(1, 1);
builder.addFunction(undefined, kSig_i_ii)
.addBodyWithEnd([
kExprI32Const, 0,
kExprLocalGet, 0,
kExprI32StoreMem, 0, 0,
kExprI32Const, 4,
kExprLocalGet, 0,
kExprI32StoreMem, 0, 0,
kExprI32Const, 8,
kExprLocalGet, 0,
kExprI32StoreMem, 0, 0,
kExprI32Const, 12,
kExprLocalGet, 0,
kExprI32StoreMem, 0, 0,
// Memory now looks like (in bytes):
// [4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0]
kExprI32Const, 0,
kSimdPrefix, kExprS128LoadMem, 0, 0,
kSimdPrefix, kExprI32x4ExtractLane, 0,
// load 32-bit from byte 4, then splat to all lanes.
kSimdPrefix, kExprS128Load32Splat, 0, 0,
kSimdPrefix, kExprI32x4ExtractLane, 3,
kExprEnd,
])
.exportAs('main');
const instance = builder.instantiate();
assertEquals(4, instance.exports.main(4));
})();