[llvm] [LV][doc] Update and extend the docs on floating-point reduction vectorization (PR #172809)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 29 09:27:43 PST 2025


================
@@ -200,7 +200,22 @@ reduction operations, such as addition, multiplication, XOR, AND and OR.
     return sum;
   }
 
-We support floating point reduction operations when `-ffast-math` is used.
+The full vectorization of reductions inherently involves reordering operations,
+which is problematic for floating-point reductions. Since floating-point
+operations are not associative, the result may depend on the order of operations.
+Therefore, vectorizing floating-point reductions is implicitly prohibited by
+the C and C++ standards, unless the compiler can ensure that the result does
+not change.
+
+For this reason, on most targets we support floating point reduction operations
+only when `-ffast-math` (or at least the `-fassociative-math -fno-signed-zeros 
+-fno-trapping-math` subset of `-ffast-math`) is used. On select targets such as
----------------
fhahn wrote:

```suggestion
Therefore LLVM supports vectorizing floating point reductions
only when at least the `-fassociative-math -fno-signed-zeros 
-fno-trapping-math` subset of `-ffast-math` is used on most targets. On select targets such as
```

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


More information about the llvm-commits mailing list