This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][Middle-end]2nd patch of PR78809 and PR83026
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: Qing Zhao <qing dot zhao at oracle dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>, Jeff Law <law at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>
- Date: Fri, 15 Dec 2017 12:41:02 +0000
- Subject: Re: [PATCH][Middle-end]2nd patch of PR78809 and PR83026
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco dot Dijkstra at arm dot com;
- Nodisclaimer: True
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi Qing,
Just looking at a very high level, I have a few comments:
1. Constant folding str(n)cmp - folding is done separately in fold-const-call.c
and gimple-fold.c. There is already code for folding strcmp and strncmp,
so we shouldn't need to add new foldings. Or do you have an example that
isn't folded as expected? If so, a fix should be added to the existing code.
2. Why check for str(n)cmp == 0 / != 0? There is no need to explicitly check
for equality comparisons since folding into memcmp is always good.
3. Why handle strncmp? There is already code to convert strncmp into strcmp,
so why repeat that again in a different way? It just seems to make the
code significantly more complex for no benefit.
You can achieve the same effect by just optimizing strcmp into memcmp when
legal without checking for equality comparison. As a result you can considerably
reduce the size of this patch while handling more useful cases.
Wilco