File tree Expand file tree Collapse file tree 3 files changed +87
-30
lines changed
src/cmd/compile/internal/ssa Expand file tree Collapse file tree 3 files changed +87
-30
lines changed Original file line number Diff line number Diff line change 961
961
(NilCheck (GetG mem) mem) => mem
962
962
963
963
(If (Not cond) yes no) => (If cond no yes)
964
- (If (Phi <t> nx:(Not x) ny:(Not y)) yes no) && nx.Uses == 1 && ny.Uses == 1 => (If (Phi <t> x y) no yes)
965
964
(If (ConstBool [c]) yes no) && c => (First yes no)
966
965
(If (ConstBool [c]) yes no) && !c => (First no yes)
967
966
967
+ (Phi <t> nx:(Not x) ny:(Not y)) && nx.Uses == 1 && ny.Uses == 1 => (Not (Phi <t> x y))
968
+
968
969
// Get rid of Convert ops for pointer arithmetic on unsafe.Pointer.
969
970
(Convert (Add(64|32) (Convert ptr mem) off) mem) => (AddPtr ptr off)
970
971
(Convert (Convert ptr mem) mem) => ptr
Original file line number Diff line number Diff line change
1
+ // compile
2
+
3
+ // Copyright 2022 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package p
8
+
9
+ func fn (setText []rune , negate bool ) int {
10
+ ranges := []singleRange {}
11
+
12
+ if len (setText ) > 0 {
13
+ fillFirst := false
14
+ l := len (setText )
15
+ if negate {
16
+ if setText [0 ] == 0 {
17
+ setText = setText [1 :]
18
+ } else {
19
+ l ++
20
+ fillFirst = true
21
+ }
22
+ }
23
+
24
+ if l % 2 == 0 {
25
+ ranges = make ([]singleRange , l / 2 )
26
+ } else {
27
+ ranges = make ([]singleRange , l / 2 + 1 )
28
+ }
29
+
30
+ first := true
31
+ if fillFirst {
32
+ ranges [0 ] = singleRange {first : 0 }
33
+ first = false
34
+ }
35
+
36
+ i := 0
37
+ for _ , r := range setText {
38
+ if first {
39
+ // lower bound in a new range
40
+ ranges [i ] = singleRange {first : r }
41
+ first = false
42
+ } else {
43
+ ranges [i ].last = r - 1
44
+ i ++
45
+ first = true
46
+ }
47
+ }
48
+ }
49
+
50
+ return len (ranges )
51
+ }
52
+
53
+ type singleRange struct {
54
+ first rune
55
+ last rune
56
+ }
You can’t perform that action at this time.
0 commit comments