cmd/6g: fix out of registers when chaining integer divisions.
Fixes #4201.
R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6622055
diff --git a/test/torture.go b/test/torture.go
index fdc5dda..dd8ff59 100644
--- a/test/torture.go
+++ b/test/torture.go
@@ -169,3 +169,25 @@
Child(0).
Child(0).(*U)
}
+
+// Chains of divisions. See issue 4201.
+
+func ChainDiv(a, b int) int {
+ return a / b / a / b / a / b / a / b /
+ a / b / a / b / a / b / a / b /
+ a / b / a / b / a / b / a / b
+}
+
+func ChainDivRight(a, b int) int {
+ return a / (b / (a / (b /
+ (a / (b / (a / (b /
+ (a / (b / (a / (b /
+ (a / (b / (a / (b /
+ (a / (b / (a / b))))))))))))))))))
+}
+
+func ChainDivConst(a int) int {
+ return a / 17 / 17 / 17 /
+ 17 / 17 / 17 / 17 /
+ 17 / 17 / 17 / 17
+}