diff options
author | Johnny Richard <johnny@johnnyrichard.com> | 2023-04-30 19:16:42 +0200 |
---|---|---|
committer | Johnny Richard <johnny@johnnyrichard.com> | 2023-04-30 19:26:30 +0200 |
commit | b1e8b4f24927efc6ed68420e4f579fb20ab831a9 (patch) | |
tree | 119496bacb2758cee773138f0bd3a452c8b6ec60 /src/lexer.h | |
parent | efe28f579b8720ea506a4e5d24ec0290223b8745 (diff) |
gas: Optimize variable reference on assembly
We were moving the stack data for variable reference to another stack
position ending up with two pointer to the same value.
// a: i32 = 1;
mov $1, -8(%rbp)
// b: i32 = a;
mov -8(%rbp), %rax
mov %rax, -24(%rbp)
mov -24(%rbp), %rax
mov %rax, -16(%rbp)
After this changes, we wont create a new temp space on stack if we don't
need it. See bellow the example after the optimization:
// a: i32 = 1;
mov $1, -8(%rbp)
// b: i32 = a;
mov -8(%rbp), %rax
mov %rax, -16(%rbp)
Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
Co-authored-by: Carlos Maniero <carlosmaniero@gmail.com>
Diffstat (limited to 'src/lexer.h')
0 files changed, 0 insertions, 0 deletions