)]}'
{
  "commit": "30144226a4ea916341c37759d93dc2b32502efa1",
  "tree": "fa48065ddfb44378a247ea4ac826218b20b4bc1c",
  "parents": [
    "f92afe7171fcda7b1b69fd428925dd7655021226"
  ],
  "author": {
    "name": "Pavel Skripkin",
    "email": "paskripkin@gmail.com",
    "time": "Thu Aug 14 10:23:03 2025 +0300"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Aug 14 10:23:03 2025 +0300"
  },
  "message": "[llvm] [InstCombine] fold \"icmp eq (X + (V - 1)) \u0026 -V, X\" to \"icmp eq (and X, V - 1), 0\" (#152851)\n\nThis fold optimizes \n\n```llvm\ndefine i1 @src(i32 %num, i32 %val) {\n  %mask \u003d add i32 %val, -1\n  %neg \u003d sub nsw i32 0, %val\n\n  %num.biased \u003d add i32 %num, %mask\n  %_2.sroa.0.0 \u003d and i32 %num.biased, %neg\n  %_0 \u003d icmp eq i32 %_2.sroa.0.0, %num\n  ret i1 %_0\n}\n```\nto\n```llvm\ndefine i1 @tgt(i32 %num, i32 %val) {\n  %mask \u003d add i32 %val, -1\n  %tmp \u003d and i32 %num, %mask\n  %ret \u003d icmp eq i32 %tmp, 0\n  ret i1 %ret\n}\n```\n\nFor power-of-two `val`.\n\nObserved in real life for following code\n\n```rust\npub fn is_aligned(num: usize) -\u003e bool {\n    num.next_multiple_of(1 \u003c\u003c 12) \u003d\u003d num\n}\n```\nwhich verifies that num is aligned to 4096.\n\nAlive2 proof https://alive2.llvm.org/ce/z/QisECm",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "cf94d2810048817c55e3232f76a3279666940f9c",
      "old_mode": 33188,
      "old_path": "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp",
      "new_id": "a64f422c3eedeffa3e7855ea1706f1b778444e65",
      "new_mode": 33188,
      "new_path": "llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp"
    },
    {
      "type": "modify",
      "old_id": "c67e27e5b3e7c38f623ad0c28cf1db7c245c87a1",
      "old_mode": 33188,
      "old_path": "llvm/lib/Transforms/InstCombine/InstCombineInternal.h",
      "new_id": "2340028ce93dc8a48d70fc7175b98dc0f6c6b9de",
      "new_mode": 33188,
      "new_path": "llvm/lib/Transforms/InstCombine/InstCombineInternal.h"
    },
    {
      "type": "modify",
      "old_id": "1a41c1f3e1045c60601cffe867fbe5eb585b4550",
      "old_mode": 33188,
      "old_path": "llvm/test/Transforms/InstCombine/icmp-add.ll",
      "new_id": "cb428097f2ae1ee82db9a3d3db0c726b33d86e54",
      "new_mode": 33188,
      "new_path": "llvm/test/Transforms/InstCombine/icmp-add.ll"
    }
  ]
}
