On Tue, Aug 16, 2016 at 03:10:13PM +0200, marxin wrote: > 2016-08-16 Martin Liska <mli...@suse.cz> > > * builtins.c (fold_builtin_strncmp): Rename to > fold_builtin_strncmp_strncasecmp and support also > strncasecmp. > (fold_builtin_3): Handle BUILT_IN_STRNCASECMP. > --- > -/* Fold function call to builtin strncmp with arguments ARG1, ARG2, and LEN. > - Return NULL_TREE if no simplification can be made. */ > +/* Fold function call to builtin strncmp (or strncasecmp) with arguments > ARG1, > + ARG2, and LEN. Return NULL_TREE if no simplification can be made. > + IS_STRNCASECMP is true for strncasecmp, false otherwise. */ > > static tree > -fold_builtin_strncmp (location_t loc, tree arg1, tree arg2, tree len) > +fold_builtin_strncmp_strncasecmp (location_t loc, tree arg1, tree arg2, > + tree len, bool is_strncasecmp) > { > if (!validate_arg (arg1, POINTER_TYPE) > || !validate_arg (arg2, POINTER_TYPE) > @@ -7442,7 +7445,8 @@ fold_builtin_strncmp (location_t loc, tree arg1, tree > arg2, tree len) > > /* If len parameter is one, return an expression corresponding to > (*(const unsigned char*)arg1 - (const unsigned char*)arg2). */ > - if (tree_fits_uhwi_p (len) && tree_to_uhwi (len) == 1) > + if (is_strncasecmp > + && tree_fits_uhwi_p (len) && tree_to_uhwi (len) == 1)
Did you really mean to use this block for strncasecmp only (rather than for strncmp only, i.e. !is_strncasecmp)? Also, while you are changing this, I'd replace tree_fits_uhwi_p (len) && tree_to_uhwi (len) == 1 with integer_onep (len). Jakub