pub fn predicate_simple_expr(e: &mut Expr) {
    e.transform_and_continue_res(&mut |ref mut e| {
        // This pattern checks for if(cond, scalar1, scalar2).
        if let If {
            ref cond,
            ref on_true,
            ref on_false,
        } = e.kind
        {
            // Check if any sub-expression has a builder; if so bail out in order to not break linearity.
            let mut safe = true;
            on_true.traverse(&mut |ref sub_expr| {
                if sub_expr.kind.is_builder_expr() {
                    safe = false;
                }
            });
            on_false.traverse(&mut |ref sub_expr| {
                if sub_expr.kind.is_builder_expr() {
                    safe = false;
                }
            });
            if !safe {
                return Ok((None, true));
            }

            // Make sure the expression is "simple": for now, that's literals, getfields, and
            // identifiers
            if !(is_simple(on_true) && is_simple(on_false)) {
                return Ok((None, true));
            }

            if let Scalar(_) = on_true.ty {
                if let Scalar(_) = on_false.ty {
                    let expr =
                        Expr::new_select(*cond.clone(), *on_true.clone(), *on_false.clone())?;
                    return Ok((Some(expr), true));
                }
            }
        }
        Ok((None, true))
    });
}
Predicate an `If` expression by checking for if(cond, scalar1, scalar2) and transforms it to select(cond, scalar1, scalar2).

Since this predicates only simple "zero-cost" expressions, it's always done.
weld/src/optimizer/transforms/vectorizer.rs