strcmp.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Optimized version of the standard strcmp() function.
  2. This file is part of the GNU C Library.
  3. Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
  4. Contributed by Dan Pop <Dan.Pop@cern.ch>.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. /* Return: the result of the comparison
  18. Inputs:
  19. in0: s1
  20. in1: s2
  21. Unlike memcmp(), this function is optimized for mismatches within the
  22. first few characters. */
  23. #include "sysdep.h"
  24. #undef ret
  25. #define s1 in0
  26. #define s2 in1
  27. #define val1 r15
  28. #define val2 r16
  29. ENTRY(strcmp)
  30. alloc r2 = ar.pfs, 2, 0, 0, 0
  31. .loop:
  32. ld1 val1 = [s1], 1
  33. ld1 val2 = [s2], 1
  34. cmp.eq p6, p0 = r0, r0 // set p6
  35. ;;
  36. cmp.ne.and p6, p0 = val1, r0
  37. cmp.ne.and p6, p0 = val2, r0
  38. cmp.eq.and p6, p0 = val1, val2
  39. (p6) br.cond.sptk .loop
  40. sub ret0 = val1, val2
  41. br.ret.sptk.many b0
  42. END(strcmp)
  43. libc_hidden_def (strcmp)