fn is_even(e: &Expr) -> bool {
    match e.kind {
        Literal(ref kind) => {
            use crate::ast::LiteralKind::*;
            match kind {
                BoolLiteral(_) => false,
                I8Literal(n) => n.is_even(),
                I16Literal(n) => n.is_even(),
                I32Literal(n) => n.is_even(),
                I64Literal(n) => n.is_even(),
                U8Literal(n) => n.is_even(),
                U16Literal(n) => n.is_even(),
                U32Literal(n) => n.is_even(),
                U64Literal(n) => n.is_even(),
                F32Literal(bits) => {
                    let n = f32::from_bits(*bits);
                    n % 2.0 == 0.0
                }
                F64Literal(bits) => {
                    let n = f64::from_bits(*bits);
                    n % 2.0 == 0.0
                }
                StringLiteral(_) => false,
            }
        }
        Ident(_) => false, // TODO might actually be true, but need to know the expression that produces that
        Negate(ref e) => is_even(e),
        BinOp {
            kind: ref k,
            left: ref l,
            right: ref r,
        } => {
            use crate::ast::BinOpKind::*;
            match k {
                Add | Subtract => is_even(l) && is_even(r), // TODO || (is_odd(l) && is_odd(r))
                Min | Max => is_even(l) && is_even(r),
                Multiply => is_even(l) || is_even(r),
                Pow => is_even(l),
                _ => false,
            }
        }
        UnaryOp { .. } => false,
        Cast {
            kind: ref k,
            child_expr: ref e,
        } => k.is_numeric() && is_even(e),
        If {
            cond: ref _c,
            on_true: ref te,
            on_false: ref fe,
        } => is_even(te) && is_even(fe),
        _ => false,
    }
}
Return true if e is definitely an even number.
May return false for expressions that are actually even, if they cannot guaranteed to be so.
weld/src/optimizer/transforms/algebraic.rs