Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate result loop when not needed #9

Open
nilslice opened this issue Mar 22, 2022 · 0 comments
Open

Eliminate result loop when not needed #9

nilslice opened this issue Mar 22, 2022 · 0 comments

Comments

@nilslice
Copy link
Contributor

In transformed IR, we insert a loop to iterate through the result data like so:

body: ; preds = %body, %body_execution
%0 = phi i64 [ %select, %body ], [ 0, %body_execution ]
%1 = phi i64 [ %4, %body ], [ 1, %body_execution ]
%2 = call i1 @get_readout_bit(%ExecutionResult* %7, i64 %1, i64 0)
%3 = zext i1 %2 to i64
%select = add i64 %0, %3
%4 = add nuw nsw i64 %1, 1
%5 = icmp ult i64 %1, 42
br i1 %5, label %body, label %body_cleanup

However, in some cases we may not have any classical instructions to interpret the result, such as:

body: ; preds = %body, %body_execution
%1 = phi i64 [ %2, %body ], [ 1, %body_execution ]
%2 = add nuw nsw i64 %1, 1
%3 = icmp ult i64 %1, 1000
br i1 %3, label %body, label %body_cleanup

In the latter case it would make sense to remove the loop, even though the program itself is not really useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant