finally struct operators fold into constant

This commit is contained in:
Jakub Doka 2024-10-30 14:10:46 +01:00
parent 4bfb5f192e
commit f6f661cee3
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
3 changed files with 31 additions and 57 deletions

View file

@ -1065,7 +1065,8 @@ impl Nodes {
break 'eliminate; break 'eliminate;
} }
if self[value].kind != Kind::Load || self[value].outputs.as_slice() != [target] if self[value].kind != Kind::Load
|| self[value].outputs.iter().any(|&n| self[n].kind != Kind::Stre)
{ {
for &ele in self[value].outputs.clone().iter().filter(|&&n| n != target) { for &ele in self[value].outputs.clone().iter().filter(|&&n| n != target) {
self[ele].peep_triggers.push(target); self[ele].peep_triggers.push(target);

View file

@ -1,37 +1,6 @@
main: main:
ADDI64 r254, r254, -64d LI64 r1, 10d
LI64 r3, 1d
ADDI64 r2, r254, 32d
ST r3, r254, 32a, 8h
LI64 r6, 2d
ST r6, r254, 40a, 8h
LI64 r6, -3d
ADDI64 r5, r254, 0d
ADDI64 r11, r254, 48d
ST r6, r254, 0a, 8h
LI64 r6, -4d
BMC r2, r11, 16h
ST r6, r254, 8a, 8h
ADDI64 r3, r5, 16d
LD r9, r254, 56a, 8h
LI64 r8, 4d
LD r10, r254, 48a, 8h
LI64 r11, 3d
BMC r2, r3, 16h
SUB64 r4, r8, r9
LD r12, r254, 24a, 8h
ADD64 r7, r10, r11
LD r1, r254, 0a, 8h
SUB64 r8, r11, r10
LD r2, r254, 16a, 8h
ADD64 r6, r12, r4
ADD64 r3, r1, r7
ADD64 r10, r2, r8
ADD64 r12, r9, r6
ADD64 r9, r10, r3
ADD64 r1, r9, r12
ADDI64 r254, r254, 64d
JALA r0, r31, 0a JALA r0, r31, 0a
code size: 308 code size: 29
ret: 10 ret: 10
status: Ok(()) status: Ok(())

View file

@ -14,30 +14,34 @@ main:
ADDI64 r254, r254, 24d ADDI64 r254, r254, 24d
JALA r0, r31, 0a JALA r0, r31, 0a
maina: maina:
ADDI64 r254, r254, -36d ADDI64 r254, r254, -28d
ST r31, r254, 28a, 8h ST r31, r254, 20a, 8h
ADDI64 r5, r254, 24d ADDI64 r5, r254, 16d
JAL r31, r0, :small_struct JAL r31, r0, :small_struct
ST r1, r254, 24a, 4h ST r1, r254, 16a, 4h
LI8 r11, 0b LI8 r9, 0b
ADDI64 r10, r254, 0d ADDI64 r1, r254, 0d
ST r11, r254, 0a, 1h ST r9, r254, 0a, 1h
ST r11, r254, 1a, 1h ST r9, r254, 1a, 1h
ST r11, r254, 2a, 1h ST r9, r254, 2a, 1h
LI8 r4, 3b LI8 r3, 3b
ST r4, r254, 3a, 1h ST r3, r254, 3a, 1h
LI8 r7, 1b LI8 r6, 1b
ST r7, r254, 4a, 1h ST r6, r254, 4a, 1h
ST r11, r254, 5a, 1h ST r9, r254, 5a, 1h
ST r11, r254, 6a, 1h ST r9, r254, 6a, 1h
ST r11, r254, 7a, 1h ST r9, r254, 7a, 1h
ADDI64 r1, r254, 8d ST r9, r254, 8a, 1h
BMC r10, r1, 8h ST r9, r254, 9a, 1h
ADDI64 r4, r1, 8d ST r9, r254, 10a, 1h
BMC r10, r4, 8h ST r3, r254, 11a, 1h
ST r6, r254, 12a, 1h
ST r9, r254, 13a, 1h
ST r9, r254, 14a, 1h
ST r9, r254, 15a, 1h
LD r1, r1, 0a, 16h LD r1, r1, 0a, 16h
LD r31, r254, 28a, 8h LD r31, r254, 20a, 8h
ADDI64 r254, r254, 36d ADDI64 r254, r254, 28d
JALA r0, r31, 0a JALA r0, r31, 0a
small_struct: small_struct:
ADDI64 r254, r254, -4d ADDI64 r254, r254, -4d
@ -48,6 +52,6 @@ small_struct:
LD r1, r3, 0a, 4h LD r1, r3, 0a, 4h
ADDI64 r254, r254, 4d ADDI64 r254, r254, 4d
JALA r0, r31, 0a JALA r0, r31, 0a
code size: 498 code size: 570
ret: 2 ret: 2
status: Ok(()) status: Ok(())