https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78809
--- Comment #29 from Wilco <wilco at gcc dot gnu.org> --- (In reply to Qing Zhao from comment #28) > > > > I don't think this is a good test. Repeatedly calling strcmp with the same > > inputs is not something real code does, especially when the string matches > > exactly. Why would it do that? The consequence is that you are probably > > optimizing for a very unlikely scenario. Instead you need to look at traces > > from real code to understand how strcmp is called in practice. Nothing else > > will give you a defensible answer. > > Please see the latest attachment to this bug, it addressed your above > concerns. > let me know if you have more concerns with the new testing cases or any > concrete > suggestion to improve the testing case. > The next step will do performance testing with SPEC2006 or SPEC2017 to > further > decide the default threshold. The new test is better, however it uses i % 15 which means an expensive division by constant every loop iteration. It's best to change to i & 15. Also using an array of string pointers means you get something like: result += strcmp (p[i & 15], "abc"); Using this I get ~80% speedup for n=3 on AArch64, similar to your set 2. As for benchmarking, I'm not so sure that SPEC2006 or SPEC2017 call strcmp with constant strings.