From 0f628b66ef92f740e4fb41ff45956211f63eb421 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 23 Dec 2017 12:53:08 +0800 Subject: Notes - More ideas for optimisations --- Notes/MIR-Optimisations.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Notes') 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 --------- -- cgit v1.2.3