)]}'
{
  "commit": "0790b52e64907c1cdd37746736a0686274a0f9ce",
  "tree": "d273bb6f4506e40842dba151fb1389f8acb5a030",
  "parents": [
    "1948a225f8f4590d2b76a833b14649f98af41a3f"
  ],
  "author": {
    "name": "Justin Hammond",
    "email": "justin@dynam.ac",
    "time": "Sat Aug 15 15:51:58 2026 +0800"
  },
  "committer": {
    "name": "Alin Jerpelea",
    "email": "alin.jerpelea@sony.com",
    "time": "Mon Aug 17 12:24:06 2026 +0200"
  },
  "message": "libs/libc/machine/risc-v: Compare a register at a time on equal offsets.\n\nmemcmp, strncmp and strcmp reach their word loops only when both pointers\nare already on a register boundary:\n\n  or    t0, a0, a1\n  andi  t0, t0, SZREG-1\n\nThat asks more than the loops need.  They load from the two pointers at\nthe same boundary, so what matters is that the two agree about where a\nboundary falls, not that either is already on one.  A pair offset by the\nsame amount can be walked up to the boundary a byte at a time and\ncompared a register at a time from there.\n\nThe union also holds far less often than the difference.  For arbitrary\npointers on RV64 it is true about one time in 64 against one in eight,\nand the case it rejects, two strings carved out of the same buffer, is\nthe common one.\n\nTest the difference of the pointers, and walk to the boundary first.\narch_strcpy.S and arch_memcpy.S already do this.  Keeping every access\naligned is not only faster here: the base ISA does not require misaligned\nloads and stores to be supported at all, so a routine in a machine\ndirectory cannot assume one will work, whatever it costs.\n\nMeasured on a 1.4 GHz rv64, source and destination misaligned by one:\n\n                    before   after\n  memcmp 32K          34.4   458.0 MB/s\n  strncmp 32K         32.4   253.0 MB/s\n  strcmp 32K          41.0   280.0 MB/s\n\nEach of those was the rate of the byte loop the word loop was meant to\nreplace.  Pointers that genuinely disagree still take the byte loop, and\nthe aligned rates are unchanged.\n\nThe measurements come from the benchmark in apache/nuttx-apps#3706.\n\nAssisted-by: Claude:claude-opus-5\nSigned-off-by: Justin Hammond \u003cjustin@dynam.ac\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3af0a4602ca82cfdee8eae711f3852f061331c39",
      "old_mode": 33188,
      "old_path": "libs/libc/machine/risc-v/arch_memcmp.S",
      "new_id": "2110c283a134ab933a7027ef3d0c2f33fca8c4a3",
      "new_mode": 33188,
      "new_path": "libs/libc/machine/risc-v/arch_memcmp.S"
    },
    {
      "type": "modify",
      "old_id": "a0bad30f602c5f5880d3a70b1dd779263b3fb37b",
      "old_mode": 33188,
      "old_path": "libs/libc/machine/risc-v/arch_strcmp.S",
      "new_id": "3ccbcfbc47b027a09dbe3fd887694ec67d0f375b",
      "new_mode": 33188,
      "new_path": "libs/libc/machine/risc-v/arch_strcmp.S"
    },
    {
      "type": "modify",
      "old_id": "df03d5fe13f24ba8bee4855ef297bd1d84f2bf9a",
      "old_mode": 33188,
      "old_path": "libs/libc/machine/risc-v/arch_strncmp.S",
      "new_id": "52bc2688d03df1a05767a6b95f9a9b9536551856",
      "new_mode": 33188,
      "new_path": "libs/libc/machine/risc-v/arch_strncmp.S"
    }
  ]
}
