)]}'
{
  "commit": "435528a4133bf61c4c25af0dca0ba2cd94facf79",
  "tree": "8e3dd81f1276d2c007bf0a6de505ec892ffb58c5",
  "parents": [
    "58bf8a355a73b7fbc6d7bfebcc7281b3cdadd4da"
  ],
  "author": {
    "name": "Dominic P",
    "email": "gcc@gcc.dp11.uk",
    "time": "Sat Aug 22 20:08:39 2026 -0600"
  },
  "committer": {
    "name": "Jeff Law",
    "email": "jeffrey.law@oss.qualcomm.com",
    "time": "Sat Aug 22 20:08:39 2026 -0600"
  },
  "message": "[PATCH 2/3] expmed: do not carry last_div_const between functions\n\nexpand_divmod remembers the constant of the last division it expanded so\nthat a following modulo by the same constant can reuse the quotient.\nThe state was a function-scope static that was never reset, so it\ncarried from one function into the next and a function\u0027s code came to\ndepend on what had been expanded before it in the translation unit.\n\nIn the new testcase m1 and m2 are character for character identical, yet\nm1 inherits the state left by d and m2 inherits the state left by m1, so\nthe two are expanded differently; reordering the functions in the source\nchanges the generated code.\n\nReset the state in prepare_function_start, which already does exactly\nthis for another cache that expansion keeps in a different file: it\nresets bitint_extended, which is defined in expr.cc and declared in\nexpr.h.  Following that precedent keeps the reset on the one path that every\nfunction\u0027s expansion goes through, including the decl-less dummy pushed\nby init_dummy_function_start, and avoids having to key the state on the\ncurrent function\u0027s identity.\n\nThis only makes the existing heuristic deterministic.  It is not a\npessimisation of the modulo it changes: at -Os -mcpu\u003darm1176jzf-s the\nreused-quotient form of m1 is six instructions and the libcall form five,\nso the testcase\u0027s m1 shrinks by one instruction as it stops depending on\nd.  Whether the heuristic should apply to a quotient that is merely the\nlast one expanded, rather than one that is actually available for reuse\nat this point, is a separate question this patch does not touch.\n\nThe series was bootstrapped on x86_64-pc-linux-gnu at trunk 7f549ea2b47\nwith the stage2/stage3 comparison successful, and a full make check shows\nno regressions: 227924 gcc and 278399 g++ expected passes, and every one\nof the 112 unexpected results also occurs with the series reverted.  With the\npatch reverted and the test kept, the test emits one\nbl __aeabi_idivmod instead of two.\n\nAssisted-by: Claude Opus 5 (Anthropic)\n\ngcc/ChangeLog:\n\n\t* expmed.cc (last_div_const): New variable, moved out of...\n\t(expand_divmod): ...here.\n\t* expmed.h (last_div_const): Declare.\n\t* function.cc (prepare_function_start): Reset last_div_const.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.target/arm/divmod-order-1.c: New test.\n\nSigned-off-by: Dominic P \u003cgcc@gcc.dp11.uk\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b87d06bc9a43da67e5a7b13d0f20fe795072313f",
      "old_mode": 33188,
      "old_path": "gcc/expmed.cc",
      "new_id": "3cfe58d4d9b2c01940439fcaea28338dbacfbf5e",
      "new_mode": 33188,
      "new_path": "gcc/expmed.cc"
    },
    {
      "type": "modify",
      "old_id": "557b58392baf21b00635813cb0b2a77e87138844",
      "old_mode": 33188,
      "old_path": "gcc/expmed.h",
      "new_id": "78f3f36e6615c9b3ee60f2b2247aaedda543928a",
      "new_mode": 33188,
      "new_path": "gcc/expmed.h"
    },
    {
      "type": "modify",
      "old_id": "5ade058d724c306565789e3f3526cb8d4faf7824",
      "old_mode": 33188,
      "old_path": "gcc/function.cc",
      "new_id": "9358787b262cbf8d4be20557c75c0f5e51d9ad19",
      "new_mode": 33188,
      "new_path": "gcc/function.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "eba68cff52a881b2d37f955a75a455dbbecb3891",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.target/arm/divmod-order-1.c"
    }
  ]
}
