aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Feature Request] Extend equality optimizations to cover reference-based operations.

Open junxzm1990 opened this issue 5 months ago • 0 comments

Compiler (tested on V2) will optimize

public fun eq1(): bool {
        1 == 1
}

to

public fun eq1(): bool {
        true
}

However, it compiles

public fun eq2(): bool {
        &1 == &1
}

to

public fun eq2(): bool {
        Eq<u64>(Borrow(Immutable)(1), Borrow(Immutable)(1))
}

Consider extending the optimizations to cover reference-based operations.

junxzm1990 avatar May 29 '25 16:05 junxzm1990