Skip to content

Commit c5ae17d

Browse files
authored
Merge pull request #27157 from DougGregor/simd-as-additivearithmetic
2 parents fa74c2f + 5285afd commit c5ae17d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

stdlib/public/core/SIMDVector.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,3 +1407,16 @@ where T: SIMD, T.Scalar: FloatingPoint {
14071407
}
14081408
return result
14091409
}
1410+
1411+
// Break the ambiguity between AdditiveArithmetic and SIMD for += and -=
1412+
extension SIMD where Self: AdditiveArithmetic, Self.Scalar: FloatingPoint {
1413+
@_alwaysEmitIntoClient
1414+
public static func +=(lhs: inout Self, rhs: Self) {
1415+
lhs = lhs + rhs
1416+
}
1417+
1418+
@_alwaysEmitIntoClient
1419+
public static func -=(lhs: inout Self, rhs: Self) {
1420+
lhs = lhs - rhs
1421+
}
1422+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-typecheck-verify-swift
2+
extension SIMD2: AdditiveArithmetic where Scalar: FloatingPoint { }
3+
extension SIMD3: AdditiveArithmetic where Scalar: FloatingPoint { }
4+
extension SIMD4: AdditiveArithmetic where Scalar: FloatingPoint { }
5+
extension SIMD8: AdditiveArithmetic where Scalar: FloatingPoint { }

0 commit comments

Comments
 (0)