...
Run Format

Source file test/fixedbugs/bug19403.go

Documentation: test/fixedbugs

     1  // run
     2  
     3  // Copyright 2017 The Go Authors.  All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // Test for golang.org/issue/19403.
     8  // F15 should not be clobbered by float-to-int conversion on ARM.
     9  // This test requires enough locals that can be put in registers that the compiler can choose to use F15.
    10  package main
    11  
    12  var count float32 = 16
    13  var i0 int
    14  var i1 int
    15  var i2 int
    16  var i3 int
    17  var i4 int
    18  var i5 int
    19  var i6 int
    20  var i7 int
    21  var i8 int
    22  var i9 int
    23  var i10 int
    24  var i11 int
    25  var i12 int
    26  var i13 int
    27  var i14 int
    28  var i15 int
    29  var i16 int
    30  
    31  func main() {
    32  	var f0 float32 = 0.0
    33  	var f1 float32 = 1.0
    34  	var f2 float32 = 2.0
    35  	var f3 float32 = 3.0
    36  	var f4 float32 = 4.0
    37  	var f5 float32 = 5.0
    38  	var f6 float32 = 6.0
    39  	var f7 float32 = 7.0
    40  	var f8 float32 = 8.0
    41  	var f9 float32 = 9.0
    42  	var f10 float32 = 10.0
    43  	var f11 float32 = 11.0
    44  	var f12 float32 = 12.0
    45  	var f13 float32 = 13.0
    46  	var f14 float32 = 14.0
    47  	var f15 float32 = 15.0
    48  	var f16 float32 = 16.0
    49  	i0 = int(f0)
    50  	i1 = int(f1)
    51  	i2 = int(f2)
    52  	i3 = int(f3)
    53  	i4 = int(f4)
    54  	i5 = int(f5)
    55  	i6 = int(f6)
    56  	i7 = int(f7)
    57  	i8 = int(f8)
    58  	i9 = int(f9)
    59  	i10 = int(f10)
    60  	i11 = int(f11)
    61  	i12 = int(f12)
    62  	i13 = int(f13)
    63  	i14 = int(f14)
    64  	i15 = int(f15)
    65  	i16 = int(f16)
    66  	if f16 != count {
    67  		panic("fail")
    68  	}
    69  	count -= 1
    70  	if f15 != count {
    71  		panic("fail")
    72  	}
    73  	count -= 1
    74  	if f14 != count {
    75  		panic("fail")
    76  	}
    77  	count -= 1
    78  	if f13 != count {
    79  		panic("fail")
    80  	}
    81  	count -= 1
    82  	if f12 != count {
    83  		panic("fail")
    84  	}
    85  	count -= 1
    86  	if f11 != count {
    87  		panic("fail")
    88  	}
    89  	count -= 1
    90  	if f10 != count {
    91  		panic("fail")
    92  	}
    93  	count -= 1
    94  	if f9 != count {
    95  		panic("fail")
    96  	}
    97  	count -= 1
    98  	if f8 != count {
    99  		panic("fail")
   100  	}
   101  	count -= 1
   102  	if f7 != count {
   103  		panic("fail")
   104  	}
   105  	count -= 1
   106  	if f6 != count {
   107  		panic("fail")
   108  	}
   109  	count -= 1
   110  	if f5 != count {
   111  		panic("fail")
   112  	}
   113  	count -= 1
   114  	if f4 != count {
   115  		panic("fail")
   116  	}
   117  	count -= 1
   118  	if f3 != count {
   119  		panic("fail")
   120  	}
   121  	count -= 1
   122  	if f2 != count {
   123  		panic("fail")
   124  	}
   125  	count -= 1
   126  	if f1 != count {
   127  		panic("fail")
   128  	}
   129  	count -= 1
   130  	if f0 != count {
   131  		panic("fail")
   132  	}
   133  	count -= 1
   134  }
   135  

View as plain text