[all-commits] [llvm/llvm-project] 82c719: [MLIR][Vector] Fix multi_reduction fold to handle ...
Mehdi Amini via All-commits
all-commits at lists.llvm.org
Mon Apr 13 10:36:29 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 82c7192a0874017a391ccfde44b0a2e4e07ca4c1
https://github.com/llvm/llvm-project/commit/82c7192a0874017a391ccfde44b0a2e4e07ca4c1
Author: Mehdi Amini <joker.eph at gmail.com>
Date: 2026-04-13 (Mon, 13 Apr 2026)
Changed paths:
M mlir/lib/Dialect/Vector/IR/VectorOps.cpp
M mlir/test/Dialect/Vector/canonicalize.mlir
Log Message:
-----------
[MLIR][Vector] Fix multi_reduction fold to handle empty reduction dims for any rank (#188983)
The fold for `vector.multi_reduction` only handled the rank-1 case with
no reduction dimensions. For higher-rank vectors (e.g.,
`vector<2x3xf32>`) with empty reduction dims `[]`, the fold returned
null, allowing `ElideUnitDimsInMultiDimReduction` to fire incorrectly.
That canonicalization pattern checks that all *reduced* dims have size
1, but with zero reduction dims the check trivially passes, and the
pattern then computes `acc op source` (e.g., `acc + source`) instead of
the correct no-op result (`source`).
This caused `--canonicalize` to produce a different value than
`--lower-vector-multi-reduction` for the same program:
vector.mask %m { vector.multi_reduction <add>, %src, %src [] :
vector<3x3xi32> to vector<3x3xi32> } : vector<3x3xi1> -> vector<3x3xi32>
* Without --lower-vector-multi-reduction: `src + src` (e.g., 2)
* With --lower-vector-multi-reduction: `src` (e.g., 1)
Fix the fold to return `source` for any rank when `reduction_dims` is
empty. This makes the empty-dims case consistent: the operation is a
noop regardless of rank, and `ElideUnitDimsInMultiDimReduction` no
longer gets a chance to mishandle it.
Fixes #129415
Assisted-by: Claude Code
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list