[Mlir-commits] [mlir] [mlir][spirv] Add folding for [I|Logical][Not]Equal (PR #74194)

Jakub Kuderski llvmlistbot at llvm.org
Mon Dec 11 10:12:38 PST 2023


================
@@ -662,19 +662,56 @@ OpFoldResult spirv::LogicalAndOp::fold(FoldAdaptor adaptor) {
   return Attribute();
 }
 
+//===----------------------------------------------------------------------===//
+// spirv.LogicalEqualOp
+//===----------------------------------------------------------------------===//
+
+OpFoldResult
+spirv::LogicalEqualOp::fold(spirv::LogicalEqualOp::FoldAdaptor adaptor) {
+  // x == x -> true
+  if (getOperand1() == getOperand2()) {
+    auto trueAttr = BoolAttr::get(getContext(), true);
+    if (isa<IntegerType>(getType())) {
+      return trueAttr;
+    }
----------------
kuhar wrote:

nit: we don't need braces around single-line if statements. also elsewhere 

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


More information about the Mlir-commits mailing list