Added isValidRewrite() to check the result of ScalarEvolutionExpander.