Is using BSF instruction instead of using GNU C __builtin_ctz inefficient?

News and research about CPU microarchitecture and software optimization
Post Reply
pauljurczak
Posts: 2
Joined: 2023-12-23, 6:25:39

Is using BSF instruction instead of using GNU C __builtin_ctz inefficient?

Post by pauljurczak » 2023-12-25, 7:35:06

I posted this question on stackoverflow: https://stackoverflow.com/questions/777 ... imd-vector. The answer claims, among others, that using "legacy BSF instruction (slow on AMD), instead of using GNU C __builtin_ctz on non-MSVC" is inefficient. Is that accurate? I find performance of VCL to be very good, but perhaps it can be even better.

agner
Site Admin
Posts: 75
Joined: 2019-12-27, 18:56:25
Contact:

Re: Is using BSF instruction instead of using GNU C __builtin_ctz inefficient?

Post by agner » 2023-12-25, 8:34:40

__builtin_ctz is not portable to all compilers. I don't think there is any difference in performance. Let's keep this discussion on stackoverflow. Remember to use the tag "vector-class-library" on stackoverflow.

Post Reply