Commit bcce5bda authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: remove NodeList != NodeList comparisons

Opt for replacements that avoid any assumptions
about the representations in use.

Passes toolstash -cmp.

Change-Id: Ia858a33abcae344e03fc1862fc9b0e192fde80c1
Reviewed-on: https://go-review.googlesource.com/20279
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 8969ab89
...@@ -2336,7 +2336,7 @@ func reorder3(all *NodeList) *NodeList { ...@@ -2336,7 +2336,7 @@ func reorder3(all *NodeList) *NodeList {
var early *NodeList var early *NodeList
var mapinit *NodeList var mapinit *NodeList
for list := all; list != nil; list = list.Next { for list, i := all, 0; list != nil; list, i = list.Next, i+1 {
l = list.N.Left l = list.N.Left
// Save subexpressions needed on left side. // Save subexpressions needed on left side.
...@@ -2348,7 +2348,7 @@ func reorder3(all *NodeList) *NodeList { ...@@ -2348,7 +2348,7 @@ func reorder3(all *NodeList) *NodeList {
} }
if l.Op == OINDEX && Isfixedarray(l.Left.Type) { if l.Op == OINDEX && Isfixedarray(l.Left.Type) {
reorder3save(&l.Right, all, list, &early) reorder3save(&l.Right, all, i, &early)
l = l.Left l = l.Left
continue continue
} }
...@@ -2364,18 +2364,18 @@ func reorder3(all *NodeList) *NodeList { ...@@ -2364,18 +2364,18 @@ func reorder3(all *NodeList) *NodeList {
break break
case OINDEX, OINDEXMAP: case OINDEX, OINDEXMAP:
reorder3save(&l.Left, all, list, &early) reorder3save(&l.Left, all, i, &early)
reorder3save(&l.Right, all, list, &early) reorder3save(&l.Right, all, i, &early)
if l.Op == OINDEXMAP { if l.Op == OINDEXMAP {
list.N = convas(list.N, &mapinit) list.N = convas(list.N, &mapinit)
} }
case OIND, ODOTPTR: case OIND, ODOTPTR:
reorder3save(&l.Left, all, list, &early) reorder3save(&l.Left, all, i, &early)
} }
// Save expression on right side. // Save expression on right side.
reorder3save(&list.N.Right, all, list, &early) reorder3save(&list.N.Right, all, i, &early)
} }
early = concat(mapinit, early) early = concat(mapinit, early)
...@@ -2383,12 +2383,12 @@ func reorder3(all *NodeList) *NodeList { ...@@ -2383,12 +2383,12 @@ func reorder3(all *NodeList) *NodeList {
} }
// if the evaluation of *np would be affected by the // if the evaluation of *np would be affected by the
// assignments in all up to but not including stop, // assignments in all up to but not including the ith assignment,
// copy into a temporary during *early and // copy into a temporary during *early and
// replace *np with that temp. // replace *np with that temp.
func reorder3save(np **Node, all *NodeList, stop *NodeList, early **NodeList) { func reorder3save(np **Node, all *NodeList, i int, early **NodeList) {
n := *np n := *np
if !aliased(n, all, stop) { if !aliased(n, all, i) {
return return
} }
...@@ -2423,8 +2423,8 @@ func outervalue(n *Node) *Node { ...@@ -2423,8 +2423,8 @@ func outervalue(n *Node) *Node {
} }
// Is it possible that the computation of n might be // Is it possible that the computation of n might be
// affected by writes in as up to but not including stop? // affected by writes in as up to but not including the ith element?
func aliased(n *Node, all *NodeList, stop *NodeList) bool { func aliased(n *Node, all *NodeList, i int) bool {
if n == nil { if n == nil {
return false return false
} }
...@@ -2438,7 +2438,7 @@ func aliased(n *Node, all *NodeList, stop *NodeList) bool { ...@@ -2438,7 +2438,7 @@ func aliased(n *Node, all *NodeList, stop *NodeList) bool {
varwrite := 0 varwrite := 0
var a *Node var a *Node
for l := all; l != stop; l = l.Next { for l := all; i > 0; l, i = l.Next, i-1 {
a = outervalue(l.N.Left) a = outervalue(l.N.Left)
if a.Op != ONAME { if a.Op != ONAME {
memwrite = 1 memwrite = 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment