[Mlir-commits] [mlir] [mlir][arith] Canonicalization patterns for `arith.select` (PR #67809)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Oct 5 09:24:30 PDT 2023


================
@@ -233,6 +233,50 @@ def CmpIExtUI :
             CPred<"$0.getValue() == arith::CmpIPredicate::eq || "
                   "$0.getValue() == arith::CmpIPredicate::ne">> $pred)]>;
 
+//===----------------------------------------------------------------------===//
+// SelectOp
+//===----------------------------------------------------------------------===//
+
+// select(not(pred), a, b) => select(pred, b, a)
+def SelectNotCond :
+    Pat<(SelectOp (Arith_XOrIOp $pred, (ConstantLikeMatcher APIntAttr:$ones)), $a, $b),
----------------
peterbell10 wrote:

My understanding is that commutative operators like `xor` are normalized so that constants always appear on the right hand side. I'll add a test to double-check.

https://github.com/llvm/llvm-project/pull/67809


More information about the Mlir-commits mailing list