Issue 124105
Summary [clang++] Loop vectorization not happening in outlined lambda function
Labels clang, clang:frontend, clang:codegen
Assignees
Reporter kavitha-natarajan
    void foo(int *A, int *B, int *C, int *D, int len) {
  auto func = [&] () {
 for (int i =0; i < len; i++)
      A[i] = B[i] * C[i] + D[i];
  };
 func();
}

$ clang++ lambda.cpp -O3 -c -S -emit-llvm -fno-unroll-loops -fno-inline

The issue is lambda is outlined into another function due to which variable "len" is loaded inside the loop. Loop bounds are not determined due to this load (compiler might be expecting alias to the load instruction). 

The original problem is in Geekbench 6.1 src/geekbench/ml/backend/cpu/depthwise_convolution_2d.cpp Line no: 402. The reason for adding "-fno-unroll-loops -fno-inline" in the above code is that for smaller functions, lambda is inlined and there is no problem in vectorization. In Geekbench, inlining doesn't happen for lambda, but outlined, and hence fails to vectorize. A good performance gain is expected in Geekbench if vectorization happens for this loop.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to