[PATCH] D21449: Target independent codesize heuristics for Loop Idiom Recognition

Sunita_Marathe via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 22 12:49:10 PDT 2016


Sunita_Marathe added a comment.

Here is the source code for Non_NestedMemset() showing the multiblock loop.
I made the if,else blocks have multiple statements to prevent SimplyCFG from converting the multi-block loop containing if-else to a single-block loop containing a select:

int APPLES, ORANGES;
int Non_NestedMemset(char *__restrict DST, int SIZE)  {

  int BASKET = 0;
  int i;
  
  for (i=0; i<SIZE; ++i) {
    DST[i] = -1;
  
    if (i % 2 == 0) {
      BASKET += APPLES;
      --ORANGES;
    }
    else {
      BASKET += ORANGES;
      --APPLES;
    }
  }
  
  return BASKET;

}

The same approach has been followed for the functions for the exempt cases.


https://reviews.llvm.org/D21449





More information about the llvm-commits mailing list