)]}'
{
  "commit": "726f91a22d1aafa4c1165fd873e7da1e18e1c5ac",
  "tree": "66c721a56d420fe44b3a035bd37e438c376c6561",
  "parents": [
    "0d0d2d2e62d26be67366babef2ef39ceb62fa878"
  ],
  "author": {
    "name": "jonathansong",
    "email": "jonathansong45@yahoo.com",
    "time": "Tue Oct 20 10:22:07 2026 +0200"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Oct 20 10:22:07 2026 +0200"
  },
  "message": "[Util] Fix crash in MergeIndexSwitchPattern when second op yields outer values (#25038)\n\nIn `MergeIndexSwitchPattern`, remapping operands of the second\n`scf.index_switch`\u0027s yields used `IRMapping::lookupOrNull`. When a\nyielded value was defined outside the switch region (e.g., hoisted\nconstants), it was absent from the mapper, resulting in a null operand\npassed to `scf::YieldOp::create` and causing a crash.\n\nSwitch to `lookupOrDefault` for the second op\u0027s yielded values, matching\nhow the first op\u0027s yields are handled. Cloned values and results of the\nfirst op are still remapped correctly, while values defined in enclosing\nscopes pass through unchanged.\n\n### Reproducer\n\nFails in `MergeIndexSwitchPattern::matchAndRewrite` →\n`scf::YieldOp::create`:\n\n```mlir\nfunc.func @main(%sel: i32) -\u003e (i32, i32) {\n  %s \u003d arith.index_cast %sel : i32 to index\n  %a \u003d scf.index_switch %s -\u003e i32\n  case 0 { %c \u003d arith.constant 10 : i32\n           scf.yield %c : i32 }\n  case 1 { %c \u003d arith.constant 11 : i32\n           scf.yield %c : i32 }\n  default { %c \u003d arith.constant 12 : i32\n            scf.yield %c : i32 }\n  %b \u003d scf.index_switch %s -\u003e i32\n  case 0 { %c \u003d arith.constant 20 : i32\n           scf.yield %c : i32 }\n  case 1 { %c \u003d arith.constant 21 : i32\n           scf.yield %c : i32 }\n  default { %c \u003d arith.constant 22 : i32\n            scf.yield %c : i32 }\n  return %a, %b : i32, i32\n}\n```\n\n```shell\niree-compile repro.mlir --iree-hal-target-device\u003dlocal \\\n  --iree-hal-local-target-device-backends\u003dvmvx -o /dev/null\n```\n\n### Changes\n\n- Use `IRMapping::lookupOrDefault` when resolving yielded values from\nthe second switch.\n- Add a regression test in `Dialect/Util/Transforms/test/patterns.mlir`\ncovering outer-scope yield values.\n\nAssisted-by: Claude Code\n\nSigned-off-by: jonathansong \u003c7958352+jonathansong@users.noreply.github.com\u003e\nCo-authored-by: jonathansong \u003c7958352+jonathansong@users.noreply.github.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "50541cae5256abb4270ba3e58134c8a7f899af3c",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/Util/Transforms/Patterns.cpp",
      "new_id": "6aee651e636295323ec5ac94747ebad8c0a1bb61",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/Util/Transforms/Patterns.cpp"
    },
    {
      "type": "modify",
      "old_id": "26b2b37592e957f53905f731149c2316cf18dac0",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Dialect/Util/Transforms/test/patterns.mlir",
      "new_id": "702e8829ca172610927e657b95c579b23ca9252f",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Dialect/Util/Transforms/test/patterns.mlir"
    }
  ]
}
