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
@@ -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
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
@@ -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
@@ -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
@@ -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
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
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-
@@ -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
@@ -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
@@ -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
@@ -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
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
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
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
15 matches
Mail list logo