Skip to content
This repository was archived by the owner on Aug 3, 2025. It is now read-only.
This repository was archived by the owner on Aug 3, 2025. It is now read-only.

Unnecessary store/load #192

@nsc-de

Description

@nsc-de

This is posted as an issue because it needs further thinking.

If we have a function like:

fun add(a: int, b: int): int {
    return a + b;
}

The compiler will output the following instructions:

istore 0
istore 4
iload 4
iload 0
iadd
iret
ret

More efficient way would be:

iadd
iret
ret

Should such edge cases be addressed? For some operators (-, /) this optimization would just work when the arguments have the correct order (for others we need swapping)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestperformancePerformance related issues / Pull requests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions