[Mlir-commits] [mlir] c7e06ce - [MLIR][LLVM] Allow inlining llvm.intr.assume.
Johannes de Fine Licht
llvmlistbot at llvm.org
Mon May 22 05:00:58 PDT 2023
Author: Johannes de Fine Licht
Date: 2023-05-22T12:00:31Z
New Revision: c7e06ce4b74789818155e0cc932f8dad4a899312
URL: https://github.com/llvm/llvm-project/commit/c7e06ce4b74789818155e0cc932f8dad4a899312
DIFF: https://github.com/llvm/llvm-project/commit/c7e06ce4b74789818155e0cc932f8dad4a899312.diff
LOG: [MLIR][LLVM] Allow inlining llvm.intr.assume.
This operation is not marked pure because it needs to survive DCE, but
is otherwise safe to inline.
Reviewed By: Dinistro
Differential Revision: https://reviews.llvm.org/D151070
Added:
Modified:
mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
mlir/test/Dialect/LLVMIR/inlining.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
index f5a4e3a7ca69..c8ff6e1ff8f3 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
@@ -340,6 +340,7 @@ struct LLVMInlinerInterface : public DialectInlinerInterface {
}
// clang-format off
if (isa<LLVM::AllocaOp,
+ LLVM::AssumeOp,
LLVM::AtomicRMWOp,
LLVM::AtomicCmpXchgOp,
LLVM::CallOp,
diff --git a/mlir/test/Dialect/LLVMIR/inlining.mlir b/mlir/test/Dialect/LLVMIR/inlining.mlir
index 564c1908e092..6ca2496bdab9 100644
--- a/mlir/test/Dialect/LLVMIR/inlining.mlir
+++ b/mlir/test/Dialect/LLVMIR/inlining.mlir
@@ -12,15 +12,16 @@ func.func @inner_func_inlinable(%ptr : !llvm.ptr) -> i32 {
llvm.intr.dbg.value #variable = %0 : i32
llvm.intr.dbg.declare #variableAddr = %ptr : !llvm.ptr
%byte = llvm.mlir.constant(43 : i8) : i8
- %volatile = llvm.mlir.constant(1 : i1) : i1
- "llvm.intr.memset"(%ptr, %byte, %0, %volatile) : (!llvm.ptr, i8, i32, i1) -> ()
- "llvm.intr.memmove"(%ptr, %ptr, %0, %volatile) : (!llvm.ptr, !llvm.ptr, i32, i1) -> ()
- "llvm.intr.memcpy"(%ptr, %ptr, %0, %volatile) : (!llvm.ptr, !llvm.ptr, i32, i1) -> ()
+ %true = llvm.mlir.constant(1 : i1) : i1
+ "llvm.intr.memset"(%ptr, %byte, %0, %true) : (!llvm.ptr, i8, i32, i1) -> ()
+ "llvm.intr.memmove"(%ptr, %ptr, %0, %true) : (!llvm.ptr, !llvm.ptr, i32, i1) -> ()
+ "llvm.intr.memcpy"(%ptr, %ptr, %0, %true) : (!llvm.ptr, !llvm.ptr, i32, i1) -> ()
+ "llvm.intr.assume"(%true) : (i1) -> ()
llvm.fence release
%2 = llvm.atomicrmw add %ptr, %0 monotonic : !llvm.ptr, i32
%3 = llvm.cmpxchg %ptr, %0, %1 acq_rel monotonic : !llvm.ptr, i32
llvm.inline_asm has_side_effects "foo", "bar" : () -> ()
- llvm.cond_br %volatile, ^bb1, ^bb2
+ llvm.cond_br %true, ^bb1, ^bb2
^bb1:
llvm.unreachable
^bb2:
@@ -39,6 +40,7 @@ func.func @inner_func_inlinable(%ptr : !llvm.ptr) -> i32 {
// CHECK: "llvm.intr.memset"(%[[PTR]]
// CHECK: "llvm.intr.memmove"(%[[PTR]], %[[PTR]]
// CHECK: "llvm.intr.memcpy"(%[[PTR]], %[[PTR]]
+// CHECK: "llvm.intr.assume"
// CHECK: llvm.fence release
// CHECK: llvm.atomicrmw add %[[PTR]], %[[CST]] monotonic
// CHECK: llvm.cmpxchg %[[PTR]], %[[CST]], %[[RES]] acq_rel monotonic
More information about the Mlir-commits
mailing list