It really takes very little for something to be impure, and optimizationsoften do it, because they end up using low-level constructs which aren't pure- some of which could be but aren't and others which probably can't be.
Just so this is clear - no optimization of the compiler is going to change the purity of a function. An optimization on the part of the programmer (like using appender) might, though.