cmd/compile: use a map to track const switch cases

This is simpler than the sorting technique.
It also allows us to simplify or eliminate
some of the sorting decisions.

Most important, sorting will not work when case clauses
represent ranges of integers: There is no correct
sort order that allows overlap detection by comparing
neighbors. Using a map allows of a cheap, simple
approach to ranges, namely to insert every int
in the map. The equivalent approach for sorting
means juggling temporary Nodes for every int,
which is a lot more expensive.

Change-Id: I84df3cb805992a1b04d14e0e4b2334f943e0ce05
Reviewed-on: https://go-review.googlesource.com/26766
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
diff --git a/test/switch5.go b/test/switch5.go
index bb0f5e3..54a11b5 100644
--- a/test/switch5.go
+++ b/test/switch5.go
@@ -79,3 +79,14 @@
 	case [1]int{0}: // OK -- see issue 15896
 	}
 }
+
+// Ensure duplicate const bool clauses are accepted.
+func f6() int {
+	switch {
+	case 0 == 0:
+		return 0
+	case 1 == 1: // Intentionally OK, even though a duplicate of the above const true
+		return 1
+	}
+	return 2
+}