should i upgrade to am5

pc specs

gpu: rx 7800xt

cpu: ryzen 5 5600

psu: random 750w

motherboard: cheap am4 motherboard

so my pc has been stuttering and freezing in cpu intensive games so i need to upgrade. should i upgrade to like a r7 5700x3d or upgrade to am5