pub fn predicate_merge_expr(e: &mut Expr) {
    e.transform_and_continue_res(&mut |ref mut e| {
        if !e.should_predicate() {
            return Ok((None, true));
        }

        // Predication for a value merged into a merger. This pattern checks for if(cond, merge(b, e), b).
        if let If {
            ref cond,
            ref on_true,
            ref on_false,
        } = e.kind
        {
            if let Merge {
                ref builder,
                ref value,
            } = on_true.kind
            {
                if let Ident(ref name) = on_false.kind {
                    if let Ident(ref name2) = builder.kind {
                        if name == name2 {
                            if let Builder(ref bk, _) = builder.ty {
                                // Merge in the identity element if the predicate fails (effectively merging in nothing)
                                let (ty, op) = match *bk {
                                    BuilderKind::Merger(ref ty, ref op) => (ty, op),
                                    BuilderKind::DictMerger(_, ref ty2, ref op) => (ty2, op),
                                    BuilderKind::VecMerger(ref ty, ref op) => (ty, op),
                                    _ => {
                                        return Ok((None, true));
                                    }
                                };

                                let identity = get_id_element(ty.as_ref(), *op)?;
                                match identity {
                                    Some(x) => {
                                        match *bk {
                                            BuilderKind::Merger(_, _)
                                            | BuilderKind::VecMerger(_, _) => {
                                                /* Change if(cond, merge(b, e), b) =>
                                                merge(b, select(cond, e, identity). */
                                                let expr = Expr::new_merge(
                                                    *builder.clone(),
                                                    Expr::new_select(
                                                        *cond.clone(),
                                                        *value.clone(),
                                                        x,
                                                    )?,
                                                )?;
                                                return Ok((Some(expr), true));
                                            }
                                            BuilderKind::DictMerger(_, _, _) => {
                                                /* For dictmerger, need to match identity element
                                                back to the key. */
                                                let sel_expr = make_select_for_kv(
                                                    *cond.clone(),
                                                    *value.clone(),
                                                    x,
                                                )?;
                                                return Ok((sel_expr, true));
                                            }
                                            _ => {
                                                return Ok((None, true));
                                            }
                                        }
                                    }
                                    None => {
                                        return Ok((None, true));
                                    }
                                };
                            }
                        }
                    }
                }
            }
        }
        Ok((None, true))
    });
}
Predicate an `If` expression by checking for if(cond, merge(b, e), b) and transforms it to
merge(b, select(cond, e,identity)).
weld/src/optimizer/transforms/vectorizer.rs