This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][Middle-end]2nd patch of PR78809 and PR83026


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]