Skip to content

Commit e8c7714

Browse files
authored
Merge pull request swiftlang#35066 from compnerd/squaring-corners
shims: add a workaround for `sqrtf` on Windows x86
2 parents 45d7861 + 4cf189f commit e8c7714

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stdlib/public/SwiftShims/LibcShims.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ float _stdlib_remainderf(float _self, float _other) {
129129

130130
static inline SWIFT_ALWAYS_INLINE
131131
float _stdlib_squareRootf(float _self) {
132+
#if defined(_WIN32) && (defined(_M_IX86) || defined(__i386__))
133+
typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
134+
return __builtin_ia32_sqrtss(__extension__ (__m128){ _self, 0, 0, 0 })[0];
135+
#else
132136
return __builtin_sqrtf(_self);
137+
#endif
133138
}
134139

135140
static inline SWIFT_ALWAYS_INLINE

0 commit comments

Comments
 (0)