How to get data sent to a LED strip each 400 ns?
This might be a fine time to look at the assembly your compiler generated, and actually consider improving it.

It's possible your stm32 has a "bit-band" region for the gpio registers, so that you can directly access that control register without any bit manipulations directly as byte address.

You might do crazily efficient stuff by not doing a manual comparison with your 0 or 1 byte, but by using conditional moves that depend on that value; that way, the fetching the value and setting the right register to the right value operations could be pipelined. If you haven't, first try different compiler flags (-O2 might be a good start) to make sure your compiler doesn't do that for you.