// branchelim tries to eliminate branches by // generating CondSelect instructions. // // Search for basic blocks that look like // // bb0 bb0 // | \ / \ // | bb1 or bb1 bb2 <- trivial if/else blocks // | / \ / // bb2 bb3 // // where the intermediate blocks are mostly empty (with no side-effects); // rewrite Phis in the postdominator as CondSelects. func branchelim(f *Func) { … } func canCondSelect(v *Value, arch string, loadAddr *sparseSet) bool { … } // elimIf converts the one-way branch starting at dom in f to a conditional move if possible. // loadAddr is a set of values which are used to compute the address of a load. // Those values are exempt from CMOV generation. func elimIf(f *Func, loadAddr *sparseSet, dom *Block) bool { … } // is this a BlockPlain with one predecessor? func isLeafPlain(b *Block) bool { … } func clobberBlock(b *Block) { … } // elimIfElse converts the two-way branch starting at dom in f to a conditional move if possible. // loadAddr is a set of values which are used to compute the address of a load. // Those values are exempt from CMOV generation. func elimIfElse(f *Func, loadAddr *sparseSet, b *Block) bool { … } // shouldElimIfElse reports whether estimated cost of eliminating branch // is lower than threshold. func shouldElimIfElse(no, yes, post *Block, arch string) bool { … } // canSpeculativelyExecute reports whether every value in the block can // be evaluated without causing any observable side effects (memory // accesses, panics and so on) except for execution time changes. It // also ensures that the block does not contain any phis which we can't // speculatively execute. // Warning: this function cannot currently detect values that represent // instructions the execution of which need to be guarded with CPU // hardware feature checks. See issue #34950. func canSpeculativelyExecute(b *Block) bool { … } func isDivMod(op Op) bool { … } func isPtrArithmetic(op Op) bool { … }