diff --git a/riscvtest/fmv.go b/riscvtest/fmv.go index cd0f02c688a1ae..97ac993f000b4e 100644 --- a/riscvtest/fmv.go +++ b/riscvtest/fmv.go @@ -2,5 +2,14 @@ package main func main() { a := float32(5) - riscvexit(int(a)) + if int(a) != 5 { + riscvexit(1) + } + + b := float32(1e6) + if b < -1e7 || b > 1e7 { + riscvexit(2) + } + + riscvexit(0) } diff --git a/src/cmd/compile/internal/riscv/ssa.go b/src/cmd/compile/internal/riscv/ssa.go index c4e5b8bfc6b56c..ab9661befb0176 100644 --- a/src/cmd/compile/internal/riscv/ssa.go +++ b/src/cmd/compile/internal/riscv/ssa.go @@ -288,7 +288,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { // Convert the float to the equivalent integer literal so we can // move it using existing infrastructure. p.From.Type = obj.TYPE_CONST - p.From.Offset = int64(math.Float32bits(float32(math.Float64frombits(uint64(v.AuxInt))))) + p.From.Offset = int64(int32(math.Float32bits(float32(math.Float64frombits(uint64(v.AuxInt)))))) p.To.Type = obj.TYPE_REG p.To.Reg = v.Reg() case ssa.OpRISCVMOVaddr: