]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: document non-commutative rule detection
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 21 Jan 2020 03:42:11 +0000 (19:42 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 20 Feb 2020 22:33:07 +0000 (22:33 +0000)
This documentation was lost in CL 213703.
This change restores it.

Change-Id: I544f15771d8a7390893efbda93478b46095ccf3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/215541
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/gen/rulegen.go

index 7c6e1b29ddc9f2bfbb4b82b7c422504bd762f0d5..47cf5f15da467e627caae26e112f84cabe0fcf36 100644 (file)
@@ -966,9 +966,16 @@ func genMatch0(rr *RuleRewrite, arch arch, match, v string, cnt map[string]int)
        commutative := op.commutative
        if commutative {
                if args[0] == args[1] {
+                       // When we have (Add x x), for any x,
+                       // even if there are other uses of x besides these two,
+                       // and even if x is not a variable,
+                       // we can skip the commutative match.
                        commutative = false
                }
                if cnt[args[0]] == 1 && cnt[args[1]] == 1 {
+                       // When we have (Add x y) with no other uses
+                       // of x and y in the matching rule and condition,
+                       // then we can skip the commutative match (Add y x).
                        commutative = false
                }
        }