File tree Expand file tree Collapse file tree
src/cmd/compile/internal/ssa Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,7 +153,6 @@ func cse(f *Func) {
153153 i ++
154154 }
155155 }
156- // TODO(khr): if value is a control value, do we need to keep it block-local?
157156 }
158157 }
159158
@@ -166,6 +165,16 @@ func cse(f *Func) {
166165 }
167166 }
168167 }
168+ if v := b .Control ; v != nil {
169+ if x := rewrite [v .ID ]; x != nil {
170+ if v .Op == OpNilCheck {
171+ // nilcheck pass will remove the nil checks and log
172+ // them appropriately, so don't mess with them here.
173+ continue
174+ }
175+ b .Control = x
176+ }
177+ }
169178 }
170179}
171180
Original file line number Diff line number Diff line change @@ -21,6 +21,15 @@ func flagalloc(f *Func) {
2121 // Walk blocks backwards. Poor-man's postorder traversal.
2222 for i := len (f .Blocks ) - 1 ; i >= 0 ; i -- {
2323 b := f .Blocks [i ]
24+ if len (b .Preds ) > 1 {
25+ // Don't use any flags register at the start
26+ // of a merge block. This causes problems
27+ // in regalloc because some of the rematerialization
28+ // instructions used on incoming merge edges clobber
29+ // the flags register.
30+ // TODO: only for architectures where this matters?
31+ continue
32+ }
2433 // Walk values backwards to figure out what flag
2534 // value we want in the flag register at the start
2635 // of the block.
Original file line number Diff line number Diff line change 370370(If (SETGF cmp) yes no) -> (UGT cmp yes no)
371371(If (SETGEF cmp) yes no) -> (UGE cmp yes no)
372372(If (SETEQF cmp) yes no) -> (EQF cmp yes no)
373- (If (SETNEF cmp) yes no) -> (EQF cmp yes no)
373+ (If (SETNEF cmp) yes no) -> (NEF cmp yes no)
374374
375375(If cond yes no) -> (NE (TESTB cond cond) yes no)
376376
Original file line number Diff line number Diff line change @@ -433,7 +433,7 @@ func init() {
433433 name : "DUFFCOPY" ,
434434 reg : regInfo {
435435 inputs : []regMask {buildReg ("DI" ), buildReg ("SI" )},
436- clobbers : buildReg ("DI SI X0" ), // uses X0 as a temporary
436+ clobbers : buildReg ("DI SI X0 FLAGS " ), // uses X0 as a temporary
437437 },
438438 },
439439
Original file line number Diff line number Diff line change @@ -3177,7 +3177,7 @@ var opcodeTable = [...]opInfo{
31773177 {0 , 128 }, // .DI
31783178 {1 , 64 }, // .SI
31793179 },
3180- clobbers : 65728 , // .SI .DI .X0
3180+ clobbers : 8590000320 , // .SI .DI .X0 .FLAGS
31813181 },
31823182 },
31833183 {
Original file line number Diff line number Diff line change @@ -14213,23 +14213,23 @@ func rewriteBlockAMD64(b *Block) bool {
1421314213 ;
1421414214 // match: (If (SETNEF cmp) yes no)
1421514215 // cond:
14216- // result: (EQF cmp yes no)
14216+ // result: (NEF cmp yes no)
1421714217 {
1421814218 v := b .Control
1421914219 if v .Op != OpAMD64SETNEF {
14220- goto endfe25939ca97349543bc2d2ce4f97ba41
14220+ goto endaa989df10b5bbc5fdf8f7f0b81767e86
1422114221 }
1422214222 cmp := v .Args [0 ]
1422314223 yes := b .Succs [0 ]
1422414224 no := b .Succs [1 ]
14225- b .Kind = BlockAMD64EQF
14225+ b .Kind = BlockAMD64NEF
1422614226 b .Control = cmp
1422714227 b .Succs [0 ] = yes
1422814228 b .Succs [1 ] = no
1422914229 return true
1423014230 }
14231- goto endfe25939ca97349543bc2d2ce4f97ba41
14232- endfe25939ca97349543bc2d2ce4f97ba41 :
14231+ goto endaa989df10b5bbc5fdf8f7f0b81767e86
14232+ endaa989df10b5bbc5fdf8f7f0b81767e86 :
1423314233 ;
1423414234 // match: (If cond yes no)
1423514235 // cond:
You can’t perform that action at this time.
0 commit comments