// phiopt eliminates boolean Phis based on the previous if. // // Main use case is to transform: // // x := false // if b { // x = true // } // // into x = b. // // In SSA code this appears as // // b0 // If b -> b1 b2 // b1 // Plain -> b2 // b2 // x = (OpPhi (ConstBool [true]) (ConstBool [false])) // // In this case we can replace x with a copy of b. func phiopt(f *Func) { … } func phioptint(v *Value, b0 *Block, reverse int) { … } // b is the If block giving the boolean value. // v is the phi value v = (OpPhi (ConstBool [true]) (ConstBool [false])). // reverse is the predecessor from which the truth value comes. func convertPhi(b *Block, v *Value, reverse int) { … }