Use native register width integer in the core loop

I noticed that there was a `uxth` (sign extending) instruction
in the hot loop of the code, because the native registers
are 32 bits but we were using a 16-bit type for the counter.
In this case, gcc emits two instructions (inc + uxth) to
increment `pulse_count` when just one would suffice.

At 120MHz, this changes the peaks from ~21/22, 34/35, 48
to 25/26, 41/42, 57.
This commit is contained in:
Jeff Epler 2022-01-03 16:14:09 -06:00
parent ca707cba20
commit cd34af79df
No known key found for this signature in database
GPG key ID: D5BF15AB975AB4DE

View file

@ -282,7 +282,7 @@ int8_t Adafruit_Floppy::track(void) { return _track; }
/**************************************************************************/
__attribute__((optimize("O3")))
uint32_t Adafruit_Floppy::capture_track(uint8_t *pulses, uint32_t max_pulses) {
uint16_t pulse_count;
unsigned pulse_count;
uint8_t *pulses_ptr = pulses;
uint8_t *pulses_end = pulses + max_pulses;