This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/78809] Inline strcmp with small constant strings
- From: "wilco at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 29 Jan 2018 12:32:33 +0000
- Subject: [Bug middle-end/78809] Inline strcmp with small constant strings
- Auto-submitted: auto-generated
- References: <bug-78809-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78809
--- Comment #31 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Qing Zhao from comment #30)
> (in reply to Wilco from comment #29)
> >
> > 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.
> I will try with these modification.
> >
> > As for benchmarking, I'm not so sure that SPEC2006 or SPEC2017 call strcmp with
> > constant strings.
> do you have any suggestion on other real applications?
Not really - I haven't seen strcmp with a constant string in a benchmark other
than Dhrystone (and that has a long string). What I typically do is get traces
from running various benchmarks and create a microbenchmark that mimicks the
behaviour, but that's probably overkill for this optimization.