[clang] [CIR] Implement switch case simplify (PR #140649)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue May 20 16:32:32 PDT 2025


andykaylor wrote:

> @andykaylor @erichkeane @bcardosolopes While implementing this simplification, I noticed a difference compared to the previous behavior where the folding happened during codegen.
> ...
> After applying the new CIR simplify pass, the output is:
> 
> ```mlir
> cir.case(anyof, [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i, #cir.int<5> : !s32i]) {
>    cir.break
> }
> ```

That's semantically equivalent, and I would say it's an improvement.

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


More information about the cfe-commits mailing list