https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119455
Bug ID: 119455
Summary: gcobol: needs optimization for direct assignments
(don't call into runtime)
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: cobol
Assignee: unassigned at gcc dot gnu.org
Reporter: simonsobisch at gnu dot org
Target Milestone: ---
Sample program:
~~~
PROGRAM-ID. STRMOV.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 dat pic x.
PROCEDURE DIVISION.
move 'a' to dat
STOP RUN.
~~~
This program has a single byte data field and assigns a single-byte.
While this assignment can easily be "inlined", it currently uses a call into
libgcobol.
To reproduce:
~~~
gcobol -g STRMOV.cob
gdb -batch -ex "set disassemble-next-line on" -ex "b STRMOV.cob:6" -ex run
a.out
~~~
Result:
~~~
Breakpoint 1, strmov () at STRMOV.cob:6
6 move 'a' to dat
=> 0x0000000000401572 <strmov+723>: 48 c7 85 20 ff ff ff 00 00 00 00
movq $0x0,-0xe0(%rbp)
0x000000000040157d <strmov+734>: 48 c7 85 18 ff ff ff 00 00 00 00
movq $0x0,-0xe8(%rbp)
0x0000000000401588 <strmov+745>: 48 8b 85 18 ff ff ff mov
-0xe8(%rbp),%rax
0x000000000040158f <strmov+752>: 41 b9 01 00 00 00 mov
$0x1,%r9d
0x0000000000401595 <strmov+758>: 41 b8 36 17 40 00 mov
$0x401736,%r8d
0x000000000040159b <strmov+764>: b9 07 00 00 00 mov $0x7,%ecx
0x00000000004015a0 <strmov+769>: ba 01 00 00 00 mov $0x1,%edx
0x00000000004015a5 <strmov+774>: 48 89 c6 mov %rax,%rsi
0x00000000004015a8 <strmov+777>: bf a0 21 60 00 mov $0x6021a0,%edi
0x00000000004015ad <strmov+782>: e8 0e fa ff ff callq 0x400fc0
<__gg__move_literala@plt>
~~~