Matt, I reviewed the code this is great because it shows what it takes to rewrite the expression. If you try this code IDEA will not like it which means that despite this tree transformation the phase we need to move this too is analysis and ir codegen with your tree algorithm