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

2025-05-22 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor closed https://github.com/llvm/llvm-project/pull/140649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-05-21 Thread via cfe-commits
@@ -186,7 +288,7 @@ void CIRSimplifyPass::runOnOperation() { // Collect operations to apply patterns. llvm::SmallVector ops; getOperation()->walk([&](Operation *op) { -if (isa(op)) +if (isa(op)) Andres-Salamanca wrote: Just checked and it also fa

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

2025-05-21 Thread via cfe-commits
https://github.com/Andres-Salamanca updated https://github.com/llvm/llvm-project/pull/140649 >From c1403f148a58e259cc296310dc21b8c5611f2e82 Mon Sep 17 00:00:00 2001 From: Andres Salamanca Date: Mon, 19 May 2025 18:53:15 -0500 Subject: [PATCH 1/3] Implement CIR switch case simplify with appropri

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

2025-05-20 Thread Andy Kaylor via cfe-commits
@@ -159,6 +159,107 @@ struct SimplifySelect : public OpRewritePattern { } }; +/// Simplify `cir.switch` operations by folding cascading cases +/// into a single `cir.case` with the `anyof` kind. +/// +/// This pattern identifies cascading cases within a `cir.switch` operati

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

2025-05-20 Thread via cfe-commits
@@ -159,6 +159,107 @@ struct SimplifySelect : public OpRewritePattern { } }; +/// Simplify `cir.switch` operations by folding cascading cases +/// into a single `cir.case` with the `anyof` kind. +/// +/// This pattern identifies cascading cases within a `cir.switch` operati

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

2025-05-20 Thread Andy Kaylor via cfe-commits
@@ -159,6 +159,107 @@ struct SimplifySelect : public OpRewritePattern { } }; +/// Simplify `cir.switch` operations by folding cascading cases +/// into a single `cir.case` with the `anyof` kind. +/// +/// This pattern identifies cascading cases within a `cir.switch` operati

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

2025-05-20 Thread Andy Kaylor via cfe-commits
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(any

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

2025-05-20 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor commented: This looks good. I have just a few minor suggestions. https://github.com/llvm/llvm-project/pull/140649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-

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

2025-05-20 Thread Andy Kaylor via cfe-commits
@@ -159,6 +159,107 @@ struct SimplifySelect : public OpRewritePattern { } }; +/// Simplify `cir.switch` operations by folding cascading cases +/// into a single `cir.case` with the `anyof` kind. +/// +/// This pattern identifies cascading cases within a `cir.switch` operati

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

2025-05-20 Thread Andy Kaylor via cfe-commits
@@ -159,6 +159,107 @@ struct SimplifySelect : public OpRewritePattern { } }; +/// Simplify `cir.switch` operations by folding cascading cases +/// into a single `cir.case` with the `anyof` kind. +/// +/// This pattern identifies cascading cases within a `cir.switch` operati

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

2025-05-20 Thread Andy Kaylor via cfe-commits
@@ -159,6 +159,107 @@ struct SimplifySelect : public OpRewritePattern { } }; +/// Simplify `cir.switch` operations by folding cascading cases +/// into a single `cir.case` with the `anyof` kind. +/// +/// This pattern identifies cascading cases within a `cir.switch` operati

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

2025-05-20 Thread Andy Kaylor via cfe-commits
@@ -0,0 +1,196 @@ +// RUN: cir-opt -cir-canonicalize -cir-simplify -o %t.cir %s +// RUN: FileCheck --input-file=%t.cir %s + +!s32i = !cir.int + +module { +cir.func @foldCascade(%arg0: !s32i) { +%0 = cir.alloca !s32i, !cir.ptr, ["a", init] {alignment = 4 : i64} +cir.sto

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

2025-05-20 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor edited https://github.com/llvm/llvm-project/pull/140649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-05-19 Thread via cfe-commits
Andres-Salamanca wrote: @andykaylor @erichkeane @bcardosolopes While implementing this simplification, I noticed a difference compared to the previous behavior where the folding happened during codegen. Consider the following test case: ```cpp void sw7(int a) { switch (a) { case 0: case

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

2025-05-19 Thread Bruno Cardoso Lopes via cfe-commits
https://github.com/bcardosolopes edited https://github.com/llvm/llvm-project/pull/140649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits