https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65668

            Bug ID: 65668
           Summary: gcc does not know how to use __eabi_uldivmod properly
           Product: gcc
           Version: 4.9.2
               URL: https://gist.github.com/mrvn/0c79b146f74c28da401f
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: goswin-v-b at web dot de
             Build: arm-none-eabi

I have a uint64_t free running counter with a frequenzy of 1Mhz and I want to
print that as hours, minutes, seconds and fraction:

    volatile uint64_t count = 0x0000000062a54bc4 // for example
    uint64_t t = count;
    uint32_t frac, seconds, minutes, hours;
    frac = t % 1000000;
    t /= 1000000;
    seconds = t % 60;
    t /= 60;
    minutes = t % 60;
    t /= 60;
    hours = t;

This results in 6 calls to __eabi_uldivmod, one for every modulo and every
division, instead of just 3 calls. With long division being rather expensive
that is a substantial waste of time.

Reply via email to