[llvm] [IR] Don't store switch case values as operands (PR #170984)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 9 00:50:12 PST 2025


aengelke wrote:

> only changing the order to make the blocks and cases contiguous rather than interleaved.

The big problem is that it would make addCase/removeCase much more expensive, which would need to move all existing case values by one slot to make space for a new block (or vice versa if case values come first). O(n^2) for adding n cases is not feasible. Having null/empty operand slots is also a bad idea (no precedent and probably much more breakage). A new addCases could be added, but it would require lots of effort to port all users... especially given that addCase is right now the "only" way to add cases.

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


More information about the llvm-commits mailing list