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

[Polly - AST Generation] Derive knowledge about loops that are known to be executed at least once #32345

Open
tobiasgrosser opened this issue May 11, 2017 · 0 comments
Labels
bugzilla Issues migrated from bugzilla polly

Comments

@tobiasgrosser
Copy link
Contributor

Bugzilla Link 32998
Version unspecified
OS Linux

Extended Description

Polly generates in lib/CodeGen/LoopGenerators.cpp:createLoop one of the two loop forms:

// BeforeBB BeforeBB
// | |
// v v
// GuardBB PreHeaderBB
// / | | _____
// __ PreHeaderBB | v / |
// / \ / | HeaderBB latch
// latch HeaderBB | |\ |
// \ / \ / | ------/
// < \ / |
// \ / v
// ExitBB ExitBB

In C, this means a loop:

for (i = LB; i <= UB; i++)
S(i);

is generated either as:

if (LB <= UB) {
long i = LB;
do {
S(i);
i++;
} while (LB <= UB);
}

or as

long i = LB;
do {
S(i);
i++;
} while (LB <= UB);

in case we can statically proof that LB <= UB. Polly can do this only for integer constants, but isl can likely proof this information a lot more often. It would be great if isl can provide this information, such that we can avoid code size increase due to the unnecessary condition. The condition likely also hinders loop invariant code motion.

Background: Polly (and LLVM in general) does this rewriting to move branches after the loop body, such that the content of the loop body can be hoisted out of the loop without any control flow branches blocking this hoisting.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla polly
Projects
None yet
Development

No branches or pull requests

1 participant