Changing flash latency from 0 to 1 even with enabled prefetch slows execution on STM32
The cache buffer in STM32F303RE is only 8 bytes (64 bits) therefore if your cycle code is longer than 8 bytes it will have no effect because the buffer is rewritten each cycle again and again.  Here, the I-cache could help you but as i see there is no I-cache in this MCU.

It is preferable to use a timer sourced from an always constant clock, like 32.768 kHz or other oscillation, to count delays. Your MCU implements many timers and the RTC, try to use one.

void delay(unsigned timertickstowait)
{
  unsigned time0 = get_current_timer_ticks_count();
  while( (unsigned)(get_current_timer_ticks_count() - time0) &lt; timertickstowait )
    { /* do nothing */ }
  return;
}


If the timer you use is sourced from a clock (frequency) independent from the MCU clock, the delay routine will be practically independent in its behavior from MCU frequency and/or Flash access parameters.