Spain is a very large country with widely scattered top-class destinations. Boiling the country down to just four overnight locations is very limiting. If I absolutely couldn't stay in more than four cities, for a May trip those cities would be Barcelona, Madrid, Seville and Granada. I'd get to Seville as early in the trip as I could because it might be getting quite hot by late May.
Granada's the smallest of those four cities; you could manage there with 3 nights if you were planning no side-trips, but I enjoyed taking the bus to Priego de Cordoba for the day, and Granada's an interesting place, so an extra night or two shouldn't be boring, assuming you enjoy walking around atmospheric neighborhoods.
I'd plan on at least five nights in Seville just to cover that city, but it has a lot of sights and could use more time for random exploration. Cordoba can be a day trip if you must, but it's worth at least a couple of nights itself. Carmona is a more laid-back side trip from Seville.
Madrid has many fabulous day-trip possibilities, starting with Toledo, Segovia, Cuenca and Alcala de Henares. The first three would be worth an overnight if you weren't wedded to the idea of just four base cities. Time needed for Madrid itself is significantly affected by how you feel about art museums. You could spend the better part of two full days just going to the Prado, Reina Sofia and Thyssen. Madrid certainly has other sights (the Royal Palace is a popular one), but to me it's the art museums that put its time requirement close to those for Seville and Barcelona. It's architecturally less distinctive than the other three cities I'm suggesting.
Barcelona has lots of sights requiring pre-purchased timed tickets, so it's great to have enough time that you don't have to schedule things too tightly; it can be a real problem to predict how much you'll spend at each sightseeing stop. I'd try for at least five nights in Barcelona, but you could add extra time for more exploration of picturesque neighborhoods. Side trips to Girona, Figueres (for the Dali Theatre-Museum) and Besalu would call for an extra day each. If all of those sound interesting to you and/or you also want to go up to Cadaques, you'd be very smart to add a fifth base, in Girona. All the other places I mentioned are shorter trips from Girona than from Barcelona.