Of course. Article 9.3:
And there are subsequent attempts at fixing that law a couple of times that only made it worse each time; like the Organic Law 4/2015, of March 30 that only broadens the definition of "hate speech" which only helps it cover arbitrary cases.
This article does not provide for the retroactive imposition of punitive rules. You seem to have missed the point that I am saying that it would not be unconstitutional in Spain because of the non-retroactivity of punitive provisions, not because it is about hate speech.
You can make whatever laws you want in Spain on hate speech, but if a law on hate speech against goats is passed today, it will start to apply from today and under no circumstances can I be punished for having spoken ill of goats yesterday or 5 years ago.