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 {
150150
151151 #[ cfg( target_arch = "aarch64" ) ]
152152 {
153+ use std:: arch:: is_aarch64_feature_detected;
154+
153155 #[ cfg( feature = "force_aarch64_generic" ) ]
154156 {
155157 return escape_generic ( input) ;
156158 }
157159 #[ cfg( not( feature = "force_aarch64_generic" ) ) ]
158160 {
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+ }
160170 }
161171 }
162172
You can’t perform that action at this time.
0 commit comments