Adjust optimization flags if the CPU does not support SSE4

Tentatively fixes #21778, #24363.