Skip to content

Implement natural loop rotation/canonicalization in GOTO programs #7211

Open

Description

@feliperodri

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

Activity

  1. added
    aws
    on Oct 5, 2022
  2. feliperodri commented on Oct 5, 2022

    @feliperodri
    CollaboratorAuthor

    It would greatly simplify our work on contracts.

  3. TGWDB commented on Oct 6, 2022

    @TGWDB
    Contributor

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

  4. tautschnig commented on Nov 14, 2022

    @tautschnig
    Collaborator

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

  5. thomasspriggs commented on Jan 31, 2023

    @thomasspriggs
    Contributor

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

  6. thomasspriggs commented on Feb 16, 2023

    @thomasspriggs
    Contributor

    This relates to #7518

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

  7. removed their assignment
    on Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    awsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions