Implement constant folding on ternary operations via fold_cond.