This is the mail archive of the 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]

cmpstrnsi pattern should check for zero byte?

I am about to put up a patch to make a change to the way
builtins.c/expand_builtin_strncmp does things. At present it will only
expand if one of the strings is a constant, and the length it passes in
is MIN(len, strlen(constant string)+1). I want to change it so that it
will also attempt to expand strncmp where neither of the input strings
is a constant.

What I ran into is that the i386 target cmpstrnsi pattern uses repz
cmpsb which does not check for the zero byte and thus depends on
expand_builtin_strncmp to arrange things so the length is not past the
end of both strings.

SH and RX are the other two targets that have cmpstrnsi patterns.

My reading of sh_expand_cmpnstr() in is that the code that it
emits will both look for a zero byte and compare the strings so it will
not have trouble with this change to expand_builtin_strncmp.

It also looks to me like emits the "scmpu" instruction to do the
comparison. The RX manual I found showed pseudocode for scmpu that
shows it both checks for zero byte as well as comparing the strings.

If this isn't correct, please let me know here or on the patch itself.


Aaron Sawdey, Ph.D.
050-2/C113  (507) 253-7520 home: 507/263-0782
IBM Linux Technology Center - PPC Toolchain

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