File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -150,13 +150,23 @@ pub fn escape<S: AsRef<str>>(input: S) -> String {
150
150
151
151
#[ cfg( target_arch = "aarch64" ) ]
152
152
{
153
+ use std:: arch:: is_aarch64_feature_detected;
154
+
153
155
#[ cfg( feature = "force_aarch64_generic" ) ]
154
156
{
155
157
return escape_generic ( input) ;
156
158
}
157
159
#[ cfg( not( feature = "force_aarch64_generic" ) ) ]
158
160
{
159
- return aarch64:: escape_neon ( input) ;
161
+ // on Apple M2 and later, the `bf16` feature is available
162
+ // it means they have more registers and can significantly benefit from the SIMD path
163
+ // TODO: add support for sve2 chips with wider registers
164
+ // github actions ubuntu-24.04-arm runner has 128 bits sve2 registers, it's not enough for the SIMD path
165
+ if cfg ! ( target_os = "macos" ) && is_aarch64_feature_detected ! ( "bf16" ) {
166
+ return aarch64:: escape_neon ( input) ;
167
+ } else {
168
+ return escape_generic ( input) ;
169
+ }
160
170
}
161
171
}
162
172
You can’t perform that action at this time.
0 commit comments