Skip to content

Loop hoisting hoists incorrect variables #282

@cardillan

Description

@cardillan

Loop hoisting is broken. It doesn't hoist instructions that the loop control variable depends on, but it happily hoists instructions that change a variable which was already read by the loop, which is incorrect:

// To make the loop hoisting change more understandable
#set data-flow-optimization = none;
var a = 0;
do
    print(a);
    a = 1;
while switch1.enabled;

produces:

set .a 0
set .a 1
print .a
sensor *tmp0 switch1 @enabled
jump 2 notEqual *tmp0 false

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingoptimizerRelated to the code optimizer

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions