[llvm] [InstCombine] Fold binary op of reductions. (PR #121567)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 05:21:11 PST 2025
RKSimon wrote:
@mgudim - I've had in mind a followup VectorCombine fold to this PR:
```ll
define i32 @src(<4 x i32> %a0, <4 x i32> %a1) {
%r0 = call i32 @llvm.vector.reduce.and.v4i32(<4 x i32> %a0)
%r1 = call i32 @llvm.vector.reduce.and.v4i32(<4 x i32> %a1)
%r = and i32 %r0, %r1
ret i32 %r
}
define i32 @tgt1(<4 x i32> %a0, <4 x i32> %a1) {
%a = and <4 x i32> %a0, %a1
%r = call i32 @llvm.vector.reduce.and.v4i32(<4 x i32> %a)
ret i32 %r
}
define i32 @tgt2(<4 x i32> %a0, <4 x i32> %a1) {
%a01 = shufflevector <4 x i32> %a0, <4 x i32> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
%r = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> %a01)
ret i32 %r
}
```
No objections if you want to move this PR to a cost driven fold in VectorCombine as well.
https://github.com/llvm/llvm-project/pull/121567
More information about the llvm-commits
mailing list