[llvm] [LV] Create in-loop sub reductions (PR #147026)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 09:06:54 PDT 2025


================
@@ -627,7 +627,7 @@ for.end:                                          ; preds = %for.body, %entry
   ret float %result.0.lcssa
 }
 
-; Sub we can create a reduction, but not inloop
+; We can create an in-loop reduction for sub-reductions by negating the input
----------------
sdesmalen-arm wrote:

Can you add a test with an interleave factor higher than 1?

I just tried building this test with ` -mllvm -prefer-inloop-reductions -mllvm -force-vector-interleave=2`:
```
int foo(int *src, int start, int n) {
  for(int i=0; i<n; ++i)
    start -= src[i];
  return start;
}
```
and this resulted in a segmentation fault.

https://github.com/llvm/llvm-project/pull/147026


More information about the llvm-commits mailing list