ridiculousfish / libdivide

Official git repository for libdivide: optimized integer division
http://libdivide.com
Other
1.09k stars 77 forks source link

Let's deprecate libdivide's unswitch functionality #46

Closed kimwalisch closed 5 years ago

kimwalisch commented 5 years ago

I have been running libdivide's benchmark program a lot over the past few days and I realized that libdivide's unswitch divider does not provide any performance speedup compared to the branchfull divider for both GCC and Clang (on x64). This is because GCC & Clang are smart enough to move the branches outside the body of the loop when using the default branchfull divider. The unswitch divider only improves performance by about 20% when using the MSVC compiler.

There are many good reasons for deprecating unswitch:

Please let me know if you agree or have if you have any objections.

kimwalisch commented 5 years ago

I have removed unswitch. I was able to get rid of about 1000 lines of code, 650 lines of code have been removed from libdivide.h. The crazy crash divider hack has been removed from libdivide.h and the C++ template implementation is now pretty clean and well designed.

I hope that using this change it will be easier for other programmers to read and understand the code inside libdivide.h and hopefully more people will contribute improvements.