modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/bug453.go (about)

     1  // run
     2  
     3  // Copyright 2012 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  // Issue 4138: bug in floating-point registers numbering.
     8  // Makes 6g unable to use more than 11 registers.
     9  
    10  package main
    11  
    12  func formula() float32 {
    13  	mA := [1]float32{1.0}
    14  	det1 := mA[0]
    15  	det2 := mA[0]
    16  	det3 := mA[0]
    17  	det4 := mA[0]
    18  	det5 := mA[0]
    19  	det6 := mA[0]
    20  	det7 := mA[0]
    21  	det8 := mA[0]
    22  	det9 := mA[0]
    23  	det10 := mA[0]
    24  	det11 := mA[0]
    25  	det12 := mA[0]
    26  
    27  	return det1 + det2*det3 +
    28  		det4*det5 + det6*det7 +
    29  		det8*det9 + det10*det11 +
    30  		det12
    31  }
    32  
    33  func main() {
    34  	x := formula()
    35  	if x != 7.0 {
    36  		println(x, 7.0)
    37  		panic("x != 7.0")
    38  	}
    39  }