wazevo(amd64): fixes u32 i->f conv with higher bits garbage (#2136)

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
Takeshi Yoneda
2024-03-08 09:05:03 +09:00
committed by GitHub
parent 687ca2f5ed
commit 464e6ce70d
4 changed files with 23 additions and 3 deletions

View File

@@ -2866,9 +2866,11 @@ func (m *machine) lowerFcvtFromUint(rn, rd operand, src64, dst64 bool) {
// >> which allows CVTSI2SS to be used after all.
//
if !src64 {
cvt := m.allocateInstr()
cvt.asGprToXmm(op, rn, rd.reg(), true)
m.insert(cvt)
// Before we convert, we have to clear the higher 32-bits of the 64-bit register
// to get the correct result.
tmp := m.c.AllocateVReg(ssa.TypeI32)
m.insert(m.allocateInstr().asMovzxRmR(extModeLQ, rn, tmp))
m.insert(m.allocateInstr().asGprToXmm(op, newOperandReg(tmp), rd.reg(), true))
return
}

View File

@@ -1056,3 +1056,10 @@ func Test2131(t *testing.T) {
}
nodiff.RequireNoDiffT(t, getWasmBinary(t, "2131"), true, true)
}
func Test2136(t *testing.T) {
if !platform.CompilerSupported() {
return
}
nodiff.RequireNoDiffT(t, getWasmBinary(t, "2136"), true, true)
}

Binary file not shown.

View File

@@ -0,0 +1,11 @@
(module
(type (;0;) (func (result f32)))
(func (;0;) (type 0) (result f32)
i32.const 0
i32.load8_s
f32.convert_i32_u
)
(memory (;0;) 3 8)
(export "" (func 0))
(data (;0;) (i32.const 0) "\f2")
)