[Mlir-commits] [mlir] dd14d47 - [mlir][OpenMP] omp.parallel side effects
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Aug 9 01:40:54 PDT 2022
Author: Shraiysh Vaishay
Date: 2022-08-09T08:40:47Z
New Revision: dd14d471a549c8b9bbcba49e3bb2bc64f4cf7e89
URL: https://github.com/llvm/llvm-project/commit/dd14d471a549c8b9bbcba49e3bb2bc64f4cf7e89
DIFF: https://github.com/llvm/llvm-project/commit/dd14d471a549c8b9bbcba49e3bb2bc64f4cf7e89.diff
LOG: [mlir][OpenMP] omp.parallel side effects
Add `NoSideEffects` trait to omp.parallel operation.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D130657
Added:
Modified:
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/test/Dialect/OpenMP/canonicalize.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index 1e1aff5624d88..466815e515650 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -125,7 +125,7 @@ def ParallelOp : OpenMP_Op<"parallel", [
}];
}
-def TerminatorOp : OpenMP_Op<"terminator", [Terminator]> {
+def TerminatorOp : OpenMP_Op<"terminator", [Terminator, NoSideEffect]> {
let summary = "terminator for OpenMP regions";
let description = [{
A terminator operation for regions that appear in the body of OpenMP
diff --git a/mlir/test/Dialect/OpenMP/canonicalize.mlir b/mlir/test/Dialect/OpenMP/canonicalize.mlir
index 61dbd81cffd91..93c3a23d2e133 100644
--- a/mlir/test/Dialect/OpenMP/canonicalize.mlir
+++ b/mlir/test/Dialect/OpenMP/canonicalize.mlir
@@ -72,3 +72,57 @@ func.func @update_unnecessary_computations(%x: memref<i32>) {
// CHECK-LABEL: func.func @update_unnecessary_computations
// CHECK-NOT: omp.atomic.update
// CHECK: omp.atomic.write
+
+// -----
+
+// CHECK-LABEL: func.func @parallel_empty
+func.func @parallel_empty() {
+ omp.parallel {}
+ return
+}
+
+// CHECK-NOT: omp.parallel
+
+// -----
+
+// CHECK-LABEL: func.func @parallel_only_terminator
+func.func @parallel_only_terminator() {
+ omp.parallel {
+ omp.terminator
+ }
+ return
+}
+
+// CHECK-NOT: omp.parallel
+// CHECK-NOT: omp.terminator
+
+// -----
+
+// CHECK-LABEL: func.func @parallel_no_side_effects
+func.func @parallel_no_side_effects(%a: i32, %b: i32) {
+ omp.parallel {
+ %x = arith.addi %a, %b : i32
+ omp.terminator
+ }
+ return
+}
+
+// CHECK-NOT: omp.parallel
+// CHECK-NOT: omp.terminator
+
+// -----
+
+// CHECK-LABEL: func.func @parallel_maybe_side_effects
+func.func @parallel_maybe_side_effects(%a: i32, %b: i32) {
+ omp.parallel {
+ func.call @foo() : () -> ()
+ omp.terminator
+ }
+ return
+}
+
+func.func private @foo() -> ()
+
+// CHECK: omp.parallel
+// CHECK: func.call @foo() : () -> ()
+// CHECK: omp.terminator
More information about the Mlir-commits
mailing list