https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98076
Bug ID: 98076
Summary: Increase speed of integer I/O
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: tkoenig at gcc dot gnu.org
Target Milestone: ---
Currently, we use GFC_INTEGER_LARGEST for a lot of integer I/O.
One place where things could be improved is gfc_itoa:
const char *
gfc_itoa (GFC_INTEGER_LARGEST n, char *buffer, size_t len)
{
...
GFC_UINTEGER_LARGEST t;
...
t = n;
if (n < 0)
{
negative = 1;
t = -n; /*must use unsigned to protect from overflow*/
}
...
while (t != 0)
{
*--p = '0' + (t % 10);
t /= 10;
}
Currently, the quotient / remainder calculation is expanded into
a libcall. This could be done by the improved remainder calculation
from PR97459 with the calculation of the quotient by multiplicative
inverse, and by switching to a smaller datatype once the value fits in
there. Both can and should be combined, of course.