[PATCH] D21720: Unroll for uncountable loops

Evgeny Stupachenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 15:01:24 PST 2017


evstupac added a comment.

PING.
Let's come to a conclusion if this is acceptable or not.
The cases that covered here:

1. Uncountable loops where previous value is reused (save one+ instruction for each value)
2. uncountable loops, that counts smth:

  while(smth) {
    body();
    n++;
  }

to:

  while(smth) {
    body();
    if (!smth) goto exit2;
    body();
    n+=2;
  }
  exit2:
  n++;
  loop exit:

Saves one+ "add" in the loop.

3. Uncountable loops switching states (not that frequent):

  while(smth) {
    body();
    s ^= n;
  }
  while(smth) {
    body();
    s = -s;
  }

Potentially saves a lot (as constant values could simplify several instructions).


Repository:
  rL LLVM

https://reviews.llvm.org/D21720





More information about the llvm-commits mailing list