)]}'
{
  "commit": "e46d96d20bbfa786d30c9371631da00939845f05",
  "tree": "510afc74a2e7d33b16301688d9f93070cccbc94a",
  "parents": [
    "2fcbe075ec3b32f4a523ebae68a8a32381bb46a9"
  ],
  "author": {
    "name": "Roger Sayle",
    "email": "roger@nextmovesoftware.com",
    "time": "Wed Jul 15 12:26:16 2026 +0100"
  },
  "committer": {
    "name": "Roger Sayle",
    "email": "roger@nextmovesoftware.com",
    "time": "Wed Jul 15 12:35:20 2026 +0100"
  },
  "message": "PR middle-end/123236: Simplify (int)((long long)x \u003e\u003e 4)\n\nThis patch addresses a code quality regression on x86_64 related to\nPR 123236.  That original PR (and the related PR 101266) concern tree\nlevel optimizations, where this problem should also be fixed, but it\nalso reveals a regression in the RTL optimizers.\n\nA motivating test case (on x86_64) is:\n\nint bar(int a) {\n  long long t \u003d a;\n  return t \u003e\u003e 4;\n}\n\nCurrently -O2 generates a 64-bit shift:\nbar:    movslq  %edi, %rax\n        sarq    $4, %rax\n        ret\n\nwith this patch we now generate a 32-bit shift:\nbar:    movl    %edi, %eax\n        sarl    $4, %eax\n        ret\n\nThe underlying cause of the RTL-level regression is that some\nRTL expressions that were previously expressed as {ZERO,SIGN}_EXTEND\nare now sometimes represented as the equivalent {ZERO,SIGN}_EXTRACT,\nand that not all simplifications of TRUNCATE({ZERO,SIGN}_EXTEND) are\nimplemented for TRUNCATE({ZERO,SIGN}_EXTRACT).\n\nThanks to Segher, simplify_rtx does handle some truncations of extracts,\nsee https://gcc.gnu.org/pipermail/gcc-patches/2016-November/463629.html\nbut unfortunately this code (and subsequent tweaks) doesn\u0027t quite match\nthe cases that appear here.\n\n2026-07-15  Roger Sayle  \u003croger@nextmovesoftware.com\u003e\n\ngcc/ChangeLog\n\tPR rtl-optimization/123236\n\t* simplify-rtx.cc (simplify_context::simplify_truncation): Handle\n\tcases where a ZERO_EXTRACT or SIGN_EXTRACT has a different mode\n\tto (but at least as wide as) its first operand.\n\ngcc/testsuite/ChangeLog\n\tPR rtl-optimization/123236\n\t* gcc.target/i386/pr123236-1.c: New test case.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "92a2a6e954a8b899fce862a1e09088a3b4c63375",
      "old_mode": 33188,
      "old_path": "gcc/simplify-rtx.cc",
      "new_id": "882a11c5760dc54ff272ac31ce0677441af6a909",
      "new_mode": 33188,
      "new_path": "gcc/simplify-rtx.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "67e872f9b2d7af0a3021b0ed416921c77643b524",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.target/i386/pr123236-1.c"
    }
  ]
}
