[Mlir-commits] [mlir] cb395b8 - [MLIR] Add not icmp canonicalization documentation
William S. Moses
llvmlistbot at llvm.org
Tue May 4 08:45:01 PDT 2021
Author: William S. Moses
Date: 2021-05-04T11:44:25-04:00
New Revision: cb395b84b09d1d411f65ae97f25c3a7a05b9bb7f
URL: https://github.com/llvm/llvm-project/commit/cb395b84b09d1d411f65ae97f25c3a7a05b9bb7f
DIFF: https://github.com/llvm/llvm-project/commit/cb395b84b09d1d411f65ae97f25c3a7a05b9bb7f.diff
LOG: [MLIR] Add not icmp canonicalization documentation
See: https://reviews.llvm.org/D101710
Added:
Modified:
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index 5b10e12c248eb..04464af904c09 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -3013,12 +3013,14 @@ OpFoldResult XOrOp::fold(ArrayRef<Attribute> operands) {
namespace {
/// Replace a not of a comparison operation, for example: not(cmp eq A, B) =>
-/// cmp ne A, B. Note that a logical not is implemented as xor 1, val
+/// cmp ne A, B. Note that a logical not is implemented as xor 1, val.
struct NotICmp : public OpRewritePattern<XOrOp> {
using OpRewritePattern<XOrOp>::OpRewritePattern;
LogicalResult matchAndRewrite(XOrOp op,
PatternRewriter &rewriter) const override {
+ // Commutative ops (such as xor) have the constant appear second, which
+ // we assume here.
APInt constValue;
if (!matchPattern(op.getOperand(1), m_ConstantInt(&constValue)))
More information about the Mlir-commits
mailing list