return uint(a)
}
+//go:noinline
+func f2i64p(v float64) *int64 {
+ return ip64(int64(v / 0.1))
+}
+
+//go:noinline
+func ip64(v int64) *int64 {
+ return &v
+}
+
func TestFloatConvert(t *testing.T) {
if got := cvt1(3.5); got != 3 {
t.Errorf("cvt1 got %d, wanted 3", got)
if got := cvt12(3.5); got != 3 {
t.Errorf("cvt12 got %d, wanted 3", got)
}
+ if got := *f2i64p(10); got != 100 {
+ t.Errorf("f2i64p got %d, wanted 100", got)
+ }
}
var sinkFloat float64
(Cvt32Fto32 (Const32F [c])) -> (Const32 [int64(int32(i2f(c)))])
(Cvt32Fto64 (Const32F [c])) -> (Const64 [int64(i2f(c))])
(Cvt64Fto32 (Const64F [c])) -> (Const32 [int64(int32(i2f(c)))])
-(Cvt64Fto64 (Const64F [c])) -> (Const32 [int64(i2f(c))])
+(Cvt64Fto64 (Const64F [c])) -> (Const64 [int64(i2f(c))])
(Round32F x:(Const32F)) -> x
(Round64F x:(Const64F)) -> x
func rewriteValuegeneric_OpCvt64Fto64_0(v *Value) bool {
// match: (Cvt64Fto64 (Const64F [c]))
// cond:
- // result: (Const32 [int64(i2f(c))])
+ // result: (Const64 [int64(i2f(c))])
for {
v_0 := v.Args[0]
if v_0.Op != OpConst64F {
break
}
c := v_0.AuxInt
- v.reset(OpConst32)
+ v.reset(OpConst64)
v.AuxInt = int64(i2f(c))
return true
}