)]}'
{
  "commit": "8b6328a247ea3f55fddf3966b796d1d3e98dda93",
  "tree": "2b83d7b063ea61664c8bf627350e9e28efae94d5",
  "parents": [
    "c1ecdbbb81bfaa05376257367877553ae8aca6e2"
  ],
  "author": {
    "name": "Zmicier Prybysh",
    "email": "zprybysh@baylibre.com",
    "time": "Tue Aug 11 18:23:04 2026 +0200"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Aug 11 16:23:04 2026 +0000"
  },
  "message": "[LLVMCPU] Use native bf16 converts when the target supports them (#24759)\n\n## Summary\n\nThe bf16 arithmetic is getting promoted to f32 in codegen, which is\ncorrect for every CPU (there\u0027s no CPU with native bf16 arithmetic yet,\nRISC-V `Zvfbfmin` provides conversions only). The conversions around\nthat promotion, however, are always expanded in software. That prevents\ntargets that do have bf16 \u003c-\u003e f32 conversion instructions from selecting\nthem, costing ~6 integer ops per narrow and 2 per widen on every bf16\nload and store.\n\nIntroduce another LLVMCPULoweringPipeline option: it\u0027s set to true on\nRISC-V targets with both `Zfbfmin` and `Zvfbfmin` extensions. Both are\nrequired, since with only the vector extension scalar bf16 residue\nlowers to `__truncsfbf2` libcalls. bf16 loads/stores and the promotion\u0027s\nextf/truncf then select as `vfwcvtbf16/vfncvtbf16` (vector) and\n`fcvt.s.bf16/fcvt.bf16.s` (scalar). This option is passed to\n`ConvertUnsupportedFloatToIntBuffers` and `arith-expand` passes.\n\n## Testing\n\nMeasured on a SpaceMiT K3 (X100 cores) (yay, i have access to one now).\n\nTested on kernels: 1M-element bf16 kernels, native vs current expansion,\noutputs bit-identical in every case:\n\n| kernel | native | expanded | speedup |\n| :-- | --: | --: | --: |\n| elementwise add | 0.800 ms | 1.45 ms | 1.81× |\n| f32 to bf16 cast | 0.650 ms | 1.01 ms | 1.55× |\n| sigmoid-weighted elementwise chain | 7.83 ms | 8.31 ms | 1.06× |\n| bf16 to f32 cast | 0.494 ms | 0.538 ms | 1.09× |\n\nAlso tested on whole models: a bf16 `whisper-tiny-en` encoder-decoder\nruns in **3.580 s vs 3.936 s (1.10×)** with bit-identical output against\nPyTorch reference. A small CLIP-style bf16 model compiles to a 7.5%\nsmaller vmfb.\n\n---------\n\nSigned-off-by: Zmicier Prybysh \u003czprybysh@baylibre.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "fda303590f3126c1891895dd2d24146f6ee283a4",
      "old_mode": 33188,
      "old_path": "compiler/plugins/target/LLVMCPU/LLVMCPUTarget.cpp",
      "new_id": "9a8ec2ecc1980e8d7481dca8715ba9de57cd2550",
      "new_mode": 33188,
      "new_path": "compiler/plugins/target/LLVMCPU/LLVMCPUTarget.cpp"
    },
    {
      "type": "modify",
      "old_id": "edb73bddd4ca8121037e8788524a73dfb4504c27",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/LLVMCPULowerExecutableTarget.cpp",
      "new_id": "d445c8adbe84769e44bf6235249a8418d972c751",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/LLVMCPULowerExecutableTarget.cpp"
    },
    {
      "type": "modify",
      "old_id": "91fa67f180f4e04610baed9a8fcfed45bad0f0fa",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp",
      "new_id": "9984e0c7de64b39a532a439dd0b73aac21166520",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp"
    },
    {
      "type": "modify",
      "old_id": "5e7124683b91450c500b77e4357ce9289db04f20",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.h",
      "new_id": "e08c1a9d18a42373a574b803b096d57a955d66c3",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.h"
    },
    {
      "type": "modify",
      "old_id": "7d1c3b227eff39471e420a56542145228a022e1b",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/Utils.cpp",
      "new_id": "d76f7c78c0f1e1384f465c1ae7c1fe55b4a0d210",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/Utils.cpp"
    },
    {
      "type": "modify",
      "old_id": "2840d0d32dc5c8a9cde7c2856e89f74939e91e46",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/Utils.h",
      "new_id": "7cbdd6390f2aa0de8eff2fb7ff22511f8e95465b",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/Utils.h"
    },
    {
      "type": "modify",
      "old_id": "7bbe65692fc1d0b85d322f0cda65b07fef957f0d",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/test/BUILD.bazel",
      "new_id": "837115daa63f4b07d62e8a269ca50d8df1a68890",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/test/BUILD.bazel"
    },
    {
      "type": "modify",
      "old_id": "25afeb85afc6a9a52166c85233c19192fee161b4",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/test/CMakeLists.txt",
      "new_id": "8d75ee9949faac2476a3581822354ce8fa1a19eb",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/test/CMakeLists.txt"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "25aeb5aba787ac312f52d60159fa8a670af20ce4",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Codegen/LLVMCPU/test/pipeline_bf16_native_converts_tests.mlir"
    }
  ]
}
