If the layoffs are announced by a new CEO being brought in to right the ship, that's totally fair. If it's the same CEO who inflated the payroll just a few years ago and is now with eyes downcast claiming "full responsibility" at the all hands when their own highly-compensated decisionmaking turned out to be a totally-unforseeable strategic mistake, then it's rather less understandable.
Perhaps the CEO learned from their mistakes and is still the right leader, but their compensation structure should be forward-looking enough that if they steered the company this far wrong along the way, then their pay incentive will naturally reflect that poor outcome. But it seems that, for example, Boeing's ousted CEO has made quite the fortune despite presiding over history-making damage to shareholder interests.