View Revisions: Issue #36427

Summary 0036427: Unneccessary movl after compile time evaluation and wrong output lines for asm register allocation
Revision 2019-12-12 20:24 by Jonas Maebe
Additional Information compiled with -O3:

    .file "y.pas"
# Begin asmlist al_procedures

.section .text.n_main
    .balign 16,0x90
.globl PASCALMAIN
    .type PASCALMAIN,@function
PASCALMAIN:
.globl main
    .type main,@function
main:
.Lc1:
# [y.pas]
# [12] begin
    pushq %rbx
    pushq %r12
    leaq -8(%rsp),%rsp
.Lc3:
# Var x located in register eax
# Var y located in register eax
# Var res1 located in register eax
# Var res2 located in register eax
    call fpc_initializeunits
# Var x located in register eax
# Var y located in register eax
# [14] y := 4;
    movl $4,%eax
# Var res1 located in register r12d
# [15] res1 := x-y;
    movl $3,%r12d
# [16] writeln(res1);
    call fpc_get_output
    movq %rax,%rbx
    movslq %r12d,%rdx
    movq %rbx,%rsi
    xorl %edi,%edi
    call fpc_write_text_sint
    call fpc_iocheck
    movq %rbx,%rdi
    call fpc_writeln_end
    call fpc_iocheck
# Var x located in register eax
# Var y located in register eax
# [19] y := 4;
    movl $4,%eax
# Var x located in register r12d
    movl $3,%r12d
# [21] writeln(x);
    call fpc_get_output
    movq %rax,%rbx
    movslq %r12d,%rdx
    movq %rbx,%rsi
    xorl %edi,%edi
    call fpc_write_text_sint
    call fpc_iocheck
    movq %rbx,%rdi
    call fpc_writeln_end
    call fpc_iocheck
# Var x located in register eax
# Var y located in register eax
# [24] y := 4;
    movl $4,%eax
# Var res2 located in register r12d
# [25] res2 := y-x;
    movl $-3,%r12d
# [26] writeln(res2);
    call fpc_get_output
    movq %rax,%rbx
    movslq %r12d,%rdx
    movq %rbx,%rsi
    xorl %edi,%edi
    call fpc_write_text_sint
    call fpc_iocheck
    movq %rbx,%rdi
    call fpc_writeln_end
    call fpc_iocheck
# Var x located in register eax
# Var y located in register eax
# [29] y := 4;
    movl $4,%eax
# Var y located in register r12d
    movl $-3,%r12d
# [31] writeln(y);
    call fpc_get_output
    movq %rax,%rbx
    movslq %r12d,%rdx
    movq %rbx,%rsi
    xorl %edi,%edi
    call fpc_write_text_sint
    call fpc_iocheck
    movq %rbx,%rdi
    call fpc_writeln_end
    call fpc_iocheck
# [32] end.
    call fpc_do_exit
    leaq 8(%rsp),%rsp
    popq %r12
    popq %rbx
    ret
.Lc2:
.Le0:
    .size main, .Le0 - main
Revision 2019-12-12 10:15 by NoName
Additional Information compiled with -O3:

    .file "y.pas"
# Begin asmlist al_procedures

.section .text.n_main
    .balign 16,0x90
.globl PASCALMAIN
    .type PASCALMAIN,@function
PASCALMAIN:
.globl main
    .type main,@function
main:
.Lc1:
# [y.pas]
# [12] begin
    pushq %rbx
    pushq %r12
    leaq -8(%rsp),%rsp
.Lc3:
# Var x located in register eax
# Var y located in register eax
# Var res1 located in register eax
# Var res2 located in register eax
    call fpc_initializeunits
# Var x located in register eax
# Var y located in register eax
# [14] y := 4;
    movl $4,%eax
# Var res1 located in register r12d
# [15] res1 := x-y;
    movl $3,%r12d
# [16] writeln(res1);
    call fpc_get_output
    movq %rax,%rbx
    movslq %r12d,%rdx
    movq %rbx,%rsi
    xorl %edi,%edi
    call fpc_write_text_sint
    call fpc_iocheck
    movq %rbx,%rdi
    call fpc_writeln_end
    call fpc_iocheck
# Var x located in register eax
# Var y located in register eax
# [19] y := 4;
    movl $4,%eax
# Var x located in register r12d
    movl $3,%r12d
# [21] writeln(x);
    call fpc_get_output
    movq %rax,%rbx
    movslq %r12d,%rdx
    movq %rbx,%rsi
    xorl %edi,%edi
    call fpc_write_text_sint
    call fpc_iocheck
    movq %rbx,%rdi
    call fpc_writeln_end
    call fpc_iocheck
# Var x located in register eax
# Var y located in register eax
# [24] y := 4;
    movl $4,%eax
# Var res2 located in register r12d
# [25] res2 := y-x;
    movl $-3,%r12d
# [26] writeln(res2);
    call fpc_get_output
    movq %rax,%rbx
    movslq %r12d,%rdx
    movq %rbx,%rsi
    xorl %edi,%edi
    call fpc_write_text_sint
    call fpc_iocheck
    movq %rbx,%rdi
    call fpc_writeln_end
    call fpc_iocheck
# Var x located in register eax
# Var y located in register eax
# [29] y := 4;
    movl $4,%eax
# Var y located in register r12d
    movl $-3,%r12d
# [31] writeln(y);
    call fpc_get_output
    movq %rax,%rbx
    movslq %r12d,%rdx
    movq %rbx,%rsi
    xorl %edi,%edi
    call fpc_write_text_sint
    call fpc_iocheck
    movq %rbx,%rdi
    call fpc_writeln_end
    call fpc_iocheck
# [32] end.
    call fpc_do_exit
    leaq 8(%rsp),%rsp
    popq %r12
    popq %rbx
    ret
.Lc2:
.Le0:
    .size main, .Le0 - main

.section .text
# End asmlist al_procedures
# Begin asmlist al_globals

.section .bss
    .balign 4
# [9] x, y: Integer;
    .type U_$P$X_$$_X,@object
    .size U_$P$X_$$_X,4
U_$P$X_$$_X:
    .zero 4

.section .bss
    .balign 4
    .type U_$P$X_$$_Y,@object
    .size U_$P$X_$$_Y,4
U_$P$X_$$_Y:
    .zero 4

.section .bss
    .balign 4
# [10] res1, res2: Integer;
    .type U_$P$X_$$_RES1,@object
    .size U_$P$X_$$_RES1,4
U_$P$X_$$_RES1:
    .zero 4

.section .bss
    .balign 4
    .type U_$P$X_$$_RES2,@object
    .size U_$P$X_$$_RES2,4
U_$P$X_$$_RES2:
    .zero 4

.section .data.n_INITFINAL
    .balign 8
.globl INITFINAL
    .type INITFINAL,@object
INITFINAL:
    .quad 4,0
    .quad INIT$_$SYSTEM
    .quad 0,0
    .quad FINALIZE$_$OBJPAS
    .quad INIT$_$UNIX
    .quad FINALIZE$_$UNIX
    .quad INIT$_$SYSUTILS
    .quad FINALIZE$_$SYSUTILS
.Le1:
    .size INITFINAL, .Le1 - INITFINAL

.section .data.n_FPC_THREADVARTABLES
    .balign 8
.globl FPC_THREADVARTABLES
    .type FPC_THREADVARTABLES,@object
FPC_THREADVARTABLES:
    .long 1
    .quad THREADVARLIST_$SYSTEM$indirect
.Le2:
    .size FPC_THREADVARTABLES, .Le2 - FPC_THREADVARTABLES

.section .data.n_FPC_RESOURCESTRINGTABLES
    .balign 8
.globl FPC_RESOURCESTRINGTABLES
    .type FPC_RESOURCESTRINGTABLES,@object
FPC_RESOURCESTRINGTABLES:
    .quad 1
    .quad RESSTR_$SYSCONST_$$_START$indirect
    .quad RESSTR_$SYSCONST_$$_END$indirect
.Le3:
    .size FPC_RESOURCESTRINGTABLES, .Le3 - FPC_RESOURCESTRINGTABLES

.section .data.n_FPC_WIDEINITTABLES
    .balign 8
.globl FPC_WIDEINITTABLES
    .type FPC_WIDEINITTABLES,@object
FPC_WIDEINITTABLES:
    .quad 0
.Le4:
    .size FPC_WIDEINITTABLES, .Le4 - FPC_WIDEINITTABLES

.section .data.n_FPC_RESSTRINITTABLES
    .balign 8
.globl FPC_RESSTRINITTABLES
    .type FPC_RESSTRINITTABLES,@object
FPC_RESSTRINITTABLES:
    .quad 0
.Le5:
    .size FPC_RESSTRINITTABLES, .Le5 - FPC_RESSTRINITTABLES

.section .fpc.n_version
    .balign 16
    .type __fpc_ident,@object
__fpc_ident:
    .ascii "FPC 3.2.0-beta-r43619 [2019/12/01] for x86_64 - Lin"
    .ascii "ux"
.Le6:
    .size __fpc_ident, .Le6 - __fpc_ident

.section .data.n___stklen
    .balign 8
.globl __stklen
    .type __stklen,@object
__stklen:
    .quad 8388608
.Le7:
    .size __stklen, .Le7 - __stklen

.section .data.n___heapsize
    .balign 8
.globl __heapsize
    .type __heapsize,@object
__heapsize:
    .quad 0
.Le8:
    .size __heapsize, .Le8 - __heapsize

.section .data.n___fpc_valgrind
    .balign 8
.globl __fpc_valgrind
    .type __fpc_valgrind,@object
__fpc_valgrind:
    .byte 0
.Le9:
    .size __fpc_valgrind, .Le9 - __fpc_valgrind

.section .data.n_FPC_RESLOCATION
    .balign 8
.globl FPC_RESLOCATION
    .type FPC_RESLOCATION,@object
FPC_RESLOCATION:
    .quad 0
.Le10:
    .size FPC_RESLOCATION, .Le10 - FPC_RESLOCATION
# End asmlist al_globals
# Begin asmlist al_dwarf_frame

.section .debug_frame
.Lc4:
    .long .Lc6-.Lc5
.Lc5:
    .long -1
    .byte 1
    .byte 0
    .uleb128 1
    .sleb128 -4
    .byte 16
    .byte 12
    .uleb128 7
    .uleb128 8
    .byte 5
    .uleb128 16
    .uleb128 2
    .balign 4,0
.Lc6:
    .long .Lc8-.Lc7
.Lc7:
    .quad .Lc4
    .quad .Lc1
    .quad .Lc2-.Lc1
    .byte 4
    .long .Lc3-.Lc1
    .byte 14
    .uleb128 16
    .balign 4,0
.Lc8:
# End asmlist al_dwarf_frame
.section .note.GNU-stack,"",%progbits