)]}'
{
  "commit": "03ab85cb873eee64da5a4a34c44955682bdc7e34",
  "tree": "cd593e597f18cbdf60bbc117d2804c67b00664d9",
  "parents": [
    "b4bc9fa1c6eec1fc4789f203326b01368bffc63b"
  ],
  "author": {
    "name": "Kiva",
    "email": "imkiva@islovely.icu",
    "time": "Mon Feb 09 22:26:07 2026 +0800"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Feb 09 22:26:07 2026 +0800"
  },
  "message": "[InstCombine] fold `gepi _, (srem x, y)` to `gepi _, (urem x, y)` if `y` is power-of-2 (#180148)\n\nThis PR adds a small, targeted InstCombine fold for the pattern:\n```\n%idx \u003d srem i64 %x, 2^k\n%p   \u003d getelementptr inbounds nuw i8, ptr %base, i64 %idx\n```\n\nWhen the GEP is inbounds + nuw, and the divisor is a non-zero\npower-of-two constant, the signed remainder cannot produce a negative\noffset without violating the inbounds/nuw constraints. In that case we\ncan canonicalize the index to a non-negative form and expose the common\npower-of-two rewrite:\n\n- Rewrite the GEP index from `srem %x, 2^k` to `urem %x, 2^k`\n- Create a new GEP with the new index and replace the original GEP\n- the `urem %x, 2^k` will further folds to `and %x (2^k-1)`\n\nresulting the following pattern\n\n```\n%idx \u003d and i64 %x, (2^k-1)\n%p   \u003d getelementptr inbounds nuw i8, ptr %base, i64 %idx\n```\n\nFixes #180097.\ngeneralized alive2 proof: https://alive2.llvm.org/ce/z/8EBxug",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "45b98dd8f419a2deb9e79da796d4412e7b4b35fd",
      "old_mode": 33188,
      "old_path": "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp",
      "new_id": "fd699381c22fabc6efef3f97d5f1ecf9303edd79",
      "new_mode": 33188,
      "new_path": "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "9f529dad5d3d17aa65606d311490ff7b8b828640",
      "new_mode": 33188,
      "new_path": "llvm/test/Transforms/InstCombine/gep-srem-to-and-deref.ll"
    }
  ]
}
