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

Sunita_Marathe via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 12 14:30:36 PDT 2016


Sunita_Marathe added a comment.

Following is an example which shows the reduced code size resulting from applying the multi-block loop heuristic:

void GF(void);

void Non_NestedMemset_55(char *__restrict D, unsigned int N)
{

  unsigned int i;
  for (i=0; i<55; ++i) {
    D[i] = 0;
    if (i>15)  GF();
  }

}

Without heuristics:

   1:   0f 57 c0                xorps  %xmm0,%xmm0
   4:   0f 11 47 20             movups %xmm0,0x20(%rdi)
   8:   0f 11 47 10             movups %xmm0,0x10(%rdi)
   c:   0f 11 07                movups %xmm0,(%rdi)
   f:   48 c7 47 2f 00 00 00    movq   $0x0,0x2f(%rdi)
  16:   00
  17:   31 db                   xor    %ebx,%ebx
  19:   48 83 fb 10             cmp    $0x10,%rbx
  1d:   72 05                   jb     24 <Non_NestedMemset_55+0x24>
  1f:   e8 00 00 00 00          callq  24 <Non_NestedMemset_55+0x24>
  24:   48 ff c3                inc    %rbx
  27:   48 83 fb 37             cmp    $0x37,%rbx
  2b:   75 ec                   jne    19 <Non_NestedMemset_55+0x19>

With heuristics:

   7:   31 db                   xor    %ebx,%ebx
   9:   41 c6 04 1e 00          movb   $0x0,(%r14,%rbx,1)
   e:   48 83 fb 10             cmp    $0x10,%rbx
  12:   72 05                   jb     19 <Non_NestedMemset_55+0x19>
  14:   e8 00 00 00 00          callq  19 <Non_NestedMemset_55+0x19>
  19:   48 ff c3                inc    %rbx
  1c:   48 83 fb 37             cmp    $0x37,%rbx
  20:   75 e7                   jne    9 <Non_NestedMemset_55+0x9>


http://reviews.llvm.org/D21449





More information about the llvm-commits mailing list