summaryrefslogtreecommitdiff
path: root/src/tools/spectest-interp.cc
diff options
context:
space:
mode:
authorMarcus Better <marcusb@users.noreply.github.com>2022-09-18 00:59:02 -0400
committerGitHub <noreply@github.com>2022-09-17 21:59:02 -0700
commitc2f10f2ce47205f8337fd2f3e7fac45385bff40c (patch)
tree2f5b802e6d24cd9124e6a3a8520546ea694a4772 /src/tools/spectest-interp.cc
parent4f88c5f08b1239f972d51cdae1ed2f36386c76b3 (diff)
downloadwabt-c2f10f2ce47205f8337fd2f3e7fac45385bff40c.tar.gz
wabt-c2f10f2ce47205f8337fd2f3e7fac45385bff40c.tar.bz2
wabt-c2f10f2ce47205f8337fd2f3e7fac45385bff40c.zip
[spectest-interp] Fix SIMD lane extraction bug (#1993)
The GetLane methods were looping over a "lane" variable, masking the parameter of the same name. This led to the last lane being returned in all cases, so tests would ignore the other lanes. Signed-off-by: Marcus Better <marcus@better.se>
Diffstat (limited to 'src/tools/spectest-interp.cc')
-rw-r--r--src/tools/spectest-interp.cc100
1 files changed, 48 insertions, 52 deletions
diff --git a/src/tools/spectest-interp.cc b/src/tools/spectest-interp.cc
index 8e0618b5..2e842dfd 100644
--- a/src/tools/spectest-interp.cc
+++ b/src/tools/spectest-interp.cc
@@ -198,41 +198,39 @@ ExpectedValue GetLane(const ExpectedValue& ev, int lane) {
v128 vec = ev.value.value.Get<v128>();
- for (int lane = 0; lane < lane_count; ++lane) {
- switch (ev.lane_type) {
- case Type::I8:
- result.nan[0] = ExpectedNan::None;
- result.value.value.Set<u32>(vec.u8(lane));
- break;
+ switch (ev.lane_type) {
+ case Type::I8:
+ result.nan[0] = ExpectedNan::None;
+ result.value.value.Set<u32>(vec.u8(lane));
+ break;
- case Type::I16:
- result.nan[0] = ExpectedNan::None;
- result.value.value.Set<u32>(vec.u16(lane));
- break;
+ case Type::I16:
+ result.nan[0] = ExpectedNan::None;
+ result.value.value.Set<u32>(vec.u16(lane));
+ break;
- case Type::I32:
- result.nan[0] = ExpectedNan::None;
- result.value.value.Set<u32>(vec.u32(lane));
- break;
+ case Type::I32:
+ result.nan[0] = ExpectedNan::None;
+ result.value.value.Set<u32>(vec.u32(lane));
+ break;
- case Type::I64:
- result.nan[0] = ExpectedNan::None;
- result.value.value.Set<u64>(vec.u64(lane));
- break;
+ case Type::I64:
+ result.nan[0] = ExpectedNan::None;
+ result.value.value.Set<u64>(vec.u64(lane));
+ break;
- case Type::F32:
- result.nan[0] = ev.nan[lane];
- result.value.value.Set<f32>(Bitcast<f32>(vec.f32_bits(lane)));
- break;
+ case Type::F32:
+ result.nan[0] = ev.nan[lane];
+ result.value.value.Set<f32>(Bitcast<f32>(vec.f32_bits(lane)));
+ break;
- case Type::F64:
- result.nan[0] = ev.nan[lane];
- result.value.value.Set<f64>(Bitcast<f64>(vec.f64_bits(lane)));
- break;
+ case Type::F64:
+ result.nan[0] = ev.nan[lane];
+ result.value.value.Set<f64>(Bitcast<f64>(vec.f64_bits(lane)));
+ break;
- default:
- WABT_UNREACHABLE;
- }
+ default:
+ WABT_UNREACHABLE;
}
return result;
}
@@ -247,35 +245,33 @@ TypedValue GetLane(const TypedValue& tv, Type lane_type, int lane) {
v128 vec = tv.value.Get<v128>();
- for (int lane = 0; lane < lane_count; ++lane) {
- switch (lane_type) {
- case Type::I8:
- result.value.Set<u32>(vec.u8(lane));
- break;
+ switch (lane_type) {
+ case Type::I8:
+ result.value.Set<u32>(vec.u8(lane));
+ break;
- case Type::I16:
- result.value.Set<u32>(vec.u16(lane));
- break;
+ case Type::I16:
+ result.value.Set<u32>(vec.u16(lane));
+ break;
- case Type::I32:
- result.value.Set<u32>(vec.u32(lane));
- break;
+ case Type::I32:
+ result.value.Set<u32>(vec.u32(lane));
+ break;
- case Type::I64:
- result.value.Set<u64>(vec.u64(lane));
- break;
+ case Type::I64:
+ result.value.Set<u64>(vec.u64(lane));
+ break;
- case Type::F32:
- result.value.Set<f32>(Bitcast<f32>(vec.f32_bits(lane)));
- break;
+ case Type::F32:
+ result.value.Set<f32>(Bitcast<f32>(vec.f32_bits(lane)));
+ break;
- case Type::F64:
- result.value.Set<f64>(Bitcast<f64>(vec.f64_bits(lane)));
- break;
+ case Type::F64:
+ result.value.Set<f64>(Bitcast<f64>(vec.f64_bits(lane)));
+ break;
- default:
- WABT_UNREACHABLE;
- }
+ default:
+ WABT_UNREACHABLE;
}
return result;
}