Skip to content

Commit af86083

Browse files
committed
cmd/compile: fix typo in floating point rule
Change-Id: Idfb64fcb26f48d5b70bab872f9a3d96a036be681 Reviewed-on: https://go-review.googlesource.com/63950 Run-TryBot: Todd Neal <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 5a986ec commit af86083

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/cmd/compile/internal/gc/float_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ func cvt12(a float32) uint {
197197
return uint(a)
198198
}
199199

200+
//go:noinline
201+
func f2i64p(v float64) *int64 {
202+
return ip64(int64(v / 0.1))
203+
}
204+
205+
//go:noinline
206+
func ip64(v int64) *int64 {
207+
return &v
208+
}
209+
200210
func TestFloatConvert(t *testing.T) {
201211
if got := cvt1(3.5); got != 3 {
202212
t.Errorf("cvt1 got %d, wanted 3", got)
@@ -234,6 +244,9 @@ func TestFloatConvert(t *testing.T) {
234244
if got := cvt12(3.5); got != 3 {
235245
t.Errorf("cvt12 got %d, wanted 3", got)
236246
}
247+
if got := *f2i64p(10); got != 100 {
248+
t.Errorf("f2i64p got %d, wanted 100", got)
249+
}
237250
}
238251

239252
var sinkFloat float64

src/cmd/compile/internal/ssa/gen/generic.rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
(Cvt32Fto32 (Const32F [c])) -> (Const32 [int64(int32(i2f(c)))])
5454
(Cvt32Fto64 (Const32F [c])) -> (Const64 [int64(i2f(c))])
5555
(Cvt64Fto32 (Const64F [c])) -> (Const32 [int64(int32(i2f(c)))])
56-
(Cvt64Fto64 (Const64F [c])) -> (Const32 [int64(i2f(c))])
56+
(Cvt64Fto64 (Const64F [c])) -> (Const64 [int64(i2f(c))])
5757
(Round32F x:(Const32F)) -> x
5858
(Round64F x:(Const64F)) -> x
5959

src/cmd/compile/internal/ssa/rewritegeneric.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)