Optimize a ? true/false : b and a ? b : true/false patterns coming from CASE