[Mlir-commits] [mlir] [mlir][spirv] Split conditional basic blocks during deserialization (PR #127639)

Igor Wodiany llvmlistbot at llvm.org
Wed Feb 19 01:36:22 PST 2025


================
@@ -2158,13 +2158,55 @@ LogicalResult spirv::Deserializer::wireUpBlockArgument() {
   return success();
 }
 
+LogicalResult spirv::Deserializer::splitConditionalBlocks() {
+  auto splitBlock = [&](Block *block) {
+    // Do not split loop headers
+    if (auto it = blockMergeInfo.find(block); it != blockMergeInfo.end()) {
+      if (it->second.continueBlock) {
+        return;
+      }
+    }
+
+    if (!block->mightHaveTerminator())
+      return;
+
+    auto terminator = block->getTerminator();
+    assert(terminator != nullptr);
+
+    if (isa<spirv::BranchConditionalOp>(terminator) &&
+        std::distance(block->begin(), block->end()) > 1) {
----------------
IgWod-IMG wrote:

This doesn't seem to work:

```
note: candidate template ignored: requirement 'std::is_base_of<std::random_access_iterator_tag, std::bidirectional_iterator_tag>::value' was not satisfied [with R = Block &]
```

I tried few other things, but it seems so far that `std::distance` is the cleanest one.

https://github.com/llvm/llvm-project/pull/127639


More information about the Mlir-commits mailing list