Skip to content

Commit ae1cee3

Browse files
committed
AArch64: significantly improve formatted input performance by using optimized libc functions on ARM64
Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>
1 parent 87c7238 commit ae1cee3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

runtime/flang/fmtread.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,8 +1624,15 @@ fr_read(char *item, /* where to transfer data to. The value of item may
16241624
if (g->curr_pos > g->obuff_len)
16251625
g->curr_pos = g->obuff_len;
16261626
else {
1627+
#ifdef TARGET_LLVM_ARM64
1628+
if (g->rec_len < g->curr_pos) {
1629+
memset(g->rec_buff + g->rec_len, ' ', g->curr_pos - g->rec_len);
1630+
g->rec_len = g->curr_pos;
1631+
}
1632+
#else
16271633
while (g->rec_len < g->curr_pos)
16281634
g->rec_buff[g->rec_len++] = ' ';
1635+
#endif
16291636
}
16301637
}
16311638
}
@@ -1713,11 +1720,23 @@ fr_read(char *item, /* where to transfer data to. The value of item may
17131720
i = fr_move_fwd(w);
17141721
if (i != 0)
17151722
return i;
1723+
#ifdef TARGET_LLVM_ARM64
1724+
memcpy(item, g->rec_buff + idx, w);
1725+
item += w;
1726+
#else
17161727
while (w-- > 0)
17171728
*item++ = g->rec_buff[idx++];
1729+
#endif
17181730
if (g->pad == FIO_YES) {
1731+
#ifdef TARGET_LLVM_ARM64
1732+
if (pad > 0) {
1733+
memset(item, ' ', pad);
1734+
item += pad;
1735+
}
1736+
#else
17191737
while (pad > 0)
17201738
*item++ = ' ', pad--;
1739+
#endif
17211740
}
17221741
}
17231742
goto exit_loop;
@@ -1749,11 +1768,23 @@ fr_read(char *item, /* where to transfer data to. The value of item may
17491768
i = fr_move_fwd(w);
17501769
if (i != 0)
17511770
return i;
1771+
#ifdef TARGET_LLVM_ARM64
1772+
memcpy(item, g->rec_buff + idx, w);
1773+
#else
17521774
while (w-- > 0)
17531775
*item++ = g->rec_buff[idx++];
1776+
item += w;
1777+
#endif
17541778
if (g->pad == FIO_YES) {
1779+
#ifdef TARGET_LLVM_ARM64
1780+
if (pad > 0) {
1781+
memset(item, ' ', pad);
1782+
item += pad;
1783+
}
1784+
#else
17551785
while (pad > 0)
17561786
*item++ = ' ', pad--;
1787+
#endif
17571788
}
17581789
goto exit_loop;
17591790
}
@@ -3199,8 +3230,15 @@ fr_move_fwd(int len)
31993230
move_fwd_eor = 1;
32003231
}
32013232

3233+
#if TARGET_LLVM_ARM64
3234+
if (g->rec_len < g->curr_pos) {
3235+
memset(g->rec_buff + g->rec_len, ' ', g->curr_pos - g->rec_len);
3236+
g->rec_len = g->curr_pos;
3237+
}
3238+
#else
32023239
while (g->rec_len < g->curr_pos)
32033240
g->rec_buff[g->rec_len++] = ' ';
3241+
#endif
32043242
}
32053243
g->max_pos = g->curr_pos;
32063244
return 0;

0 commit comments

Comments
 (0)