[PATCH] D73670: [MLIR] Allow non-binary operations to be commutative

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 16:59:42 PST 2020


rriddle requested changes to this revision.
rriddle added inline comments.
This revision now requires changes to proceed.


================
Comment at: mlir/lib/Transforms/Utils/FoldUtils.cpp:142
+                            Attribute c;
+                            matchPattern(O.get(), m_Constant(&c));
+                            return (bool)!c;
----------------
You should be able to do something like:

```
return matchPattern(O.get(), m_Constant());
```


================
Comment at: mlir/test/Transforms/test-canonicalize.mlir:48
+
+  // CHECK-NEXT: %1 = "test.op_commutative"(%arg0, %arg1, %c42_i32, %c43_i32) : (i32, i32, i32, i32) -> i32
+  %z = "test.op_commutative"(%arg0, %c42_i32, %c43_i32, %arg1): (i32, i32, i32, i32) -> i32
----------------
Don't check SSA values directly:

https://mlir.llvm.org/getting_started/TestingGuide/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73670/new/

https://reviews.llvm.org/D73670





More information about the llvm-commits mailing list