Source file test/fixedbugs/bug452.go

     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 3835: 8g tries to optimize arithmetic involving integer
     8  // constants, but can run out of registers in the process.
     9  
    10  package main
    11  
    12  var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G int
    13  
    14  func foo() int {
    15  	return a + 1 + b + 2 + c + 3 + d + 4 + e + 5 + f + 6 + g + 7 + h + 8 + i + 9 + j + 10 +
    16  		k + 1 + l + 2 + m + 3 + n + 4 + o + 5 + p + 6 + q + 7 + r + 8 + s + 9 + t + 10 +
    17  		u + 1 + v + 2 + w + 3 + x + 4 + y + 5 + z + 6 + A + 7 + B + 8 + C + 9 + D + 10 +
    18  		E + 1 + F + 2 + G + 3
    19  }
    20  
    21  func bar() int8 {
    22  	var (
    23  		W int16
    24  		X int32
    25  		Y int32
    26  		Z int32
    27  	)
    28  	return int8(W+int16(X+3)+3) * int8(Y+3+Z*3)
    29  }
    30  
    31  func main() {
    32  	if foo() == 0 {
    33  		panic("foo")
    34  	}
    35  	if bar() == 0 {
    36  		panic("bar")
    37  	}
    38  }
    39  

View as plain text