[mlir][llvm] Mark additional ops as pure.
authorTobias Gysi <tobias.gysi@nextsilicon.com>
Wed, 17 May 2023 11:25:24 +0000 (11:25 +0000)
committerTobias Gysi <tobias.gysi@nextsilicon.com>
Wed, 17 May 2023 11:25:39 +0000 (11:25 +0000)
The revision marks the overflow arithmetic intrinsics
and the freeze operation as pure. This change enables
inlining and possible other optimizations for these
operations.

Reviewed By: Dinistro

Differential Revision: https://reviews.llvm.org/D150679

mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

index 03c3979..7ac68c9 100644 (file)
@@ -251,7 +251,7 @@ def LLVM_LifetimeEndOp : LLVM_LifetimeBaseOp<"lifetime.end"> {
 // Intrinsics with multiple returns.
 
 class LLVM_ArithWithOverflowOp<string mnem>
-    : LLVM_IntrOp<mnem, [0], [], [SameOperandsElementType], 2>,
+    : LLVM_IntrOp<mnem, [0], [], [Pure, SameOperandsElementType], 2>,
       Arguments<(ins LLVM_ScalarOrVectorOf<AnySignlessInteger>,
                  LLVM_ScalarOrVectorOf<AnySignlessInteger>)>;
 
index 3ead2d2..e6aed10 100644 (file)
@@ -797,7 +797,7 @@ def LLVM_SelectOp
     $res = op;
   }];
 }
-def LLVM_FreezeOp : LLVM_Op<"freeze", [SameOperandsAndResultType]> {
+def LLVM_FreezeOp : LLVM_Op<"freeze", [Pure, SameOperandsAndResultType]> {
   let arguments = (ins LLVM_Type:$val);
   let results = (outs LLVM_Type:$res);
   let builders = [LLVM_OneResultOpBuilder];