Skip to content

[WebAssembly] narrow_i16x8_u miscompile #201780

@nikic

Description

@nikic
define <16 x i8> @test(<8 x i16> %arg) {
  %min = tail call <8 x i16> @llvm.umin.v8i16(<8 x i16> %arg, <8 x i16> splat (i16 255))
  %shuf = shufflevector <8 x i16> %min, <8 x i16> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
  %trunc = trunc nuw <16 x i16> %shuf to <16 x i8>
  ret <16 x i8> %trunc
}

Produces:

test:                                   # @test
        local.get       0
        local.get       0
        i8x16.narrow_i16x8_u
        end_function

The umin is missing.

Likely introduced by #155470.

It seems like the assumption was that the wasm instruction implements TRUNCATE_USAT_U, but what it actually seems to implement is TRUNCATE_SSAT_U.

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions