i++
}
}
- // TODO(khr): if value is a control value, do we need to keep it block-local?
}
}
}
}
}
+ if v := b.Control; v != nil {
+ if x := rewrite[v.ID]; x != nil {
+ if v.Op == OpNilCheck {
+ // nilcheck pass will remove the nil checks and log
+ // them appropriately, so don't mess with them here.
+ continue
+ }
+ b.Control = x
+ }
+ }
}
}
// Walk blocks backwards. Poor-man's postorder traversal.
for i := len(f.Blocks) - 1; i >= 0; i-- {
b := f.Blocks[i]
+ if len(b.Preds) > 1 {
+ // Don't use any flags register at the start
+ // of a merge block. This causes problems
+ // in regalloc because some of the rematerialization
+ // instructions used on incoming merge edges clobber
+ // the flags register.
+ // TODO: only for architectures where this matters?
+ continue
+ }
// Walk values backwards to figure out what flag
// value we want in the flag register at the start
// of the block.
(If (SETGF cmp) yes no) -> (UGT cmp yes no)
(If (SETGEF cmp) yes no) -> (UGE cmp yes no)
(If (SETEQF cmp) yes no) -> (EQF cmp yes no)
-(If (SETNEF cmp) yes no) -> (EQF cmp yes no)
+(If (SETNEF cmp) yes no) -> (NEF cmp yes no)
(If cond yes no) -> (NE (TESTB cond cond) yes no)
name: "DUFFCOPY",
reg: regInfo{
inputs: []regMask{buildReg("DI"), buildReg("SI")},
- clobbers: buildReg("DI SI X0"), // uses X0 as a temporary
+ clobbers: buildReg("DI SI X0 FLAGS"), // uses X0 as a temporary
},
},
{0, 128}, // .DI
{1, 64}, // .SI
},
- clobbers: 65728, // .SI .DI .X0
+ clobbers: 8590000320, // .SI .DI .X0 .FLAGS
},
},
{
;
// match: (If (SETNEF cmp) yes no)
// cond:
- // result: (EQF cmp yes no)
+ // result: (NEF cmp yes no)
{
v := b.Control
if v.Op != OpAMD64SETNEF {
- goto endfe25939ca97349543bc2d2ce4f97ba41
+ goto endaa989df10b5bbc5fdf8f7f0b81767e86
}
cmp := v.Args[0]
yes := b.Succs[0]
no := b.Succs[1]
- b.Kind = BlockAMD64EQF
+ b.Kind = BlockAMD64NEF
b.Control = cmp
b.Succs[0] = yes
b.Succs[1] = no
return true
}
- goto endfe25939ca97349543bc2d2ce4f97ba41
- endfe25939ca97349543bc2d2ce4f97ba41:
+ goto endaa989df10b5bbc5fdf8f7f0b81767e86
+ endaa989df10b5bbc5fdf8f7f0b81767e86:
;
// match: (If cond yes no)
// cond: