summaryrefslogtreecommitdiff
path: root/Notes
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-12-23 12:53:08 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-12-23 12:53:08 +0800
commit0f628b66ef92f740e4fb41ff45956211f63eb421 (patch)
tree2b496db49c6f2957d8a6c4cb56ed35c0eeae4f00 /Notes
parentc54c79b06fcbb369a9df82d2f526def0cb2b4474 (diff)
downloadmrust-0f628b66ef92f740e4fb41ff45956211f63eb421.tar.gz
Notes - More ideas for optimisations
Diffstat (limited to 'Notes')
-rw-r--r--Notes/MIR-Optimisations.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/Notes/MIR-Optimisations.md b/Notes/MIR-Optimisations.md
index e83f7cd3..57f29c88 100644
--- a/Notes/MIR-Optimisations.md
+++ b/Notes/MIR-Optimisations.md
@@ -91,6 +91,18 @@ fn do_replacements(stmt)
```
+Reverse De-temporary
+====================
+
+Allows removing useless temporaries (e.g. function returns)
+
+IDEA ONLY.
+- Find `... = Local(n)`
+- Find where it was defined
+- If the destination was invalidated in that time, don't do anything
+- If it's mutated or otherwise accessed in the intervening time, don't do anything with it
+- If the value is Copy and it's used elsewhere, don't do anything
+- Otherwise, remove the assignment and move upwards
Return Backprop
===============
@@ -119,6 +131,10 @@ Remove assignments where the assigned value isn't read/borrowed before next assi
Algorithm
---------
+- For all assignments of the form `Local(n) = ...`, seek forwards until the next use or loopback
+- If the next use of that particular lvalue is an assignment, delete the original assignment
+- If the lvalue is fully reassigned, delete the original assignment
+ - Fully reassignment means that the LHS of Index/Field is mutated
Pseudocode
---------