mirror of
https://github.com/golang/go
synced 2024-09-05 16:04:50 +00:00
6g,8g: make constant propagation inlining-friendly.
This changes makes constant propagation compare 'from' values using node pointers rather than symbol names when checking to see whether a set operation is redundant. When a function is inlined multiple times in a calling function its arguments will share symbol names even though the values are different. Prior to this fix the bug409 test would hit a case with 6g where an LEAQ instruction was incorrectly eliminated from the second inlined function call. 8g appears to have had the same bug, but the test did not fail there. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5646044
This commit is contained in:
parent
1460cce081
commit
fff732ea2c
|
@ -987,7 +987,7 @@ loop:
|
|||
case 3: // set
|
||||
if(p->as == p0->as)
|
||||
if(p->from.type == p0->from.type)
|
||||
if(p->from.sym == p0->from.sym)
|
||||
if(p->from.node == p0->from.node)
|
||||
if(p->from.offset == p0->from.offset)
|
||||
if(p->from.scale == p0->from.scale)
|
||||
if(p->from.dval == p0->from.dval)
|
||||
|
|
|
@ -878,7 +878,7 @@ loop:
|
|||
case 3: // set
|
||||
if(p->as == p0->as)
|
||||
if(p->from.type == p0->from.type)
|
||||
if(p->from.sym == p0->from.sym)
|
||||
if(p->from.node == p0->from.node)
|
||||
if(p->from.offset == p0->from.offset)
|
||||
if(p->from.scale == p0->from.scale)
|
||||
if(p->from.dval == p0->from.dval)
|
||||
|
|
20
test/fixedbugs/bug409.go
Normal file
20
test/fixedbugs/bug409.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
// $G $D/$F.go && $L $F.$A && ./$A.out 2>&1 | cmp - $D/$F.out
|
||||
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Multiple inlined calls to a function that causes
|
||||
// redundant address loads.
|
||||
|
||||
package main
|
||||
|
||||
func F(v [2]float64) [2]float64 {
|
||||
return [2]float64{v[0], v[1]}
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := F([2]float64{1, 2})
|
||||
b := F([2]float64{3, 4})
|
||||
println(a[0], a[1], b[0], b[1])
|
||||
}
|
1
test/fixedbugs/bug409.out
Normal file
1
test/fixedbugs/bug409.out
Normal file
|
@ -0,0 +1 @@
|
|||
+1.000000e+000 +2.000000e+000 +3.000000e+000 +4.000000e+000
|
Loading…
Reference in a new issue