[PATCH] D105216: [ScalarEvolution] Fix overflow in computeBECount.

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 9 03:34:18 PDT 2021


shchenz added a comment.

Yeah, we also found issue on PowerPC target. Reducing a small case:

  __attribute__((noinline))int foo(int *arr)
  {
    int prime = 0, k = 0;
  
    for(int i = 0; i < 8191; i++) {
      prime = i + i + 1; 
      k = i + prime;
      for (int j = k; j < 8191; j += prime)
        arr[j] = 0;
    }
    return 0;
  }
  int main(void)
  {
    int arr[8191];
  
    foo (arr);
    return 0;
  }



  $ clang -O2 t.cpp ; ./a.out
  Segmentation fault (core dumped)

`-fno-vectorize` can make above case pass. Initial investigation shows that after this patch, the loop execution count for the vectorized loop now can be wrap, so generate unexpected behaviour.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105216/new/

https://reviews.llvm.org/D105216



More information about the llvm-commits mailing list