Only constant-fold indexing if it is valid.