Generalize ScalarEvolution's cast-folding code to support more kinds