Skip to content

Implement natural loop rotation/canonicalization in GOTO programs #7211

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

Open
feliperodri opened this issue Oct 5, 2022 · 5 comments
Open
Labels
aws Bugs or features of importance to AWS CBMC users enhancement

Comments

@feliperodri
Copy link
Collaborator

CBMC version: 5.67.0
Operating system: N/A

Problem description

Let us consider a natural loop and the sequence of its instructions in the order in which they appear in the goto program.

The problem is that the sequence of loop instructions not necessarily densely packed in the goto program instruction sequence, meaning, the span of instructions between the first and the last loop instruction can contain instructions that are not part of the loop (typically, code that is only run once when breaking out of the loop)

This makes it difficult to apply loop transformations (in particular assigns clause instrumentation and loop contracts transformations), because these foreign instructions need to be preserved in the transformed loop.

LLVM loop canonicalisation could be a source of inspiration. loop canonicalisation ensures that loop instruction sequences are densely packed in the program's instruction sequence and that the loop has a single entry point and single exit point. The body of the loop can be swapped as a block, and code that needs to be hoisted out of the loop can safely be moved either to the single loop entry or the single loop exit location.

https://llvm.org/docs/LoopTerminology.html
https://llvm.org/devmtg/2009-10/ScalarEvolutionAndLoopOptimization.pdf
https://llvm.org/devmtg/2018-10/slides/Kruse-LoopTransforms.pdf

@feliperodri feliperodri added enhancement aws Bugs or features of importance to AWS CBMC users aws-high labels Oct 5, 2022
@feliperodri
Copy link
Collaborator Author

It would greatly simplify our work on contracts.

@TGWDB
Copy link
Contributor

TGWDB commented Oct 6, 2022

@diffblue/diffblue-opensource This tag might work where we cannot "assign" this to the Team.

@tautschnig
Copy link
Collaborator

Just a note that #7321 might partially take care of this.

@thomasspriggs
Copy link
Contributor

I am scheduled to look at this issue once I finish my currently assigned task.

@thomasspriggs
Copy link
Contributor

This relates to #7518

My team has re-prioritised some of the work. I now have other documentation to write first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users enhancement
Projects
None yet
Development

No branches or pull requests

4 participants