fn remove_common_subexpressions(
        &mut self,
        expr: &mut Expr,
        bindings: &mut HashMap<Expr, Symbol>,
    ) {
        expr.transform_up(&mut |ref mut e| {
            if !e.use_cse() {
                return None;
            }

            let e = e.take();
            let ty = e.ty.clone();

            let name = bindings
                .entry(e)
                .or_insert_with(&mut || self.sym_gen.new_symbol("cse"))
                .clone();

            // Replace the expression with its CSE name.
            let replacement = Expr {
                ty,
                kind: Ident(name),
                annotations: Annotations::new(),
            };

            Some(replacement)
        });
    }
Removes common subexpressions and remove bindings.

This method updates the bindings map to hold expression to identifier information for each
subexpression in the given expression tree. The expressions can be looked up in the
bindings map to find common subexpressions.
weld/src/optimizer/transforms/cse.rs