Skip to content

Commit 7b46941

Browse files
committed
Add fast path in generic matmul
This manually adds the critical optimisation investigated in Julia issue 56954. While we could rely on LLVM to continue doing this optimisation, it's more robust to add it manually.
1 parent 2a1696a commit 7b46941

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/matmul.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ function _generic_matmatmul_nonadjtrans!(C, A, B, alpha, beta)
10211021
@inbounds for n in axes(B, 2), k in axes(B, 1)
10221022
# Balpha = B[k,n] * alpha, but we skip the multiplication in case isone(alpha)
10231023
Balpha = @stable_muladdmul MulAddMul(alpha, false)(B[k,n])
1024+
iszero(Balpha) && continue
10241025
@simd for m in axes(A, 1)
10251026
C[m,n] = muladd(A[m,k], Balpha, C[m,n])
10261027
end

0 commit comments

Comments
 (0)