[PATCH] D75764: [mlir] Create a std op instead of chain of ops.

Han-Chung Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 12:09:05 PST 2020


hanchung created this revision.
hanchung added reviewers: nicolasvasilache, mravishankar, asaadaldien, antiagainst.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.

1-bit integer is tricky in different dialects sometimes. E.g., there is no
arithmetic instructions on 1-bit integer in SPIR-V. It's better to create the op
directly, and this also match the semantic better.

Also add assertions on inputs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75764

Files:
  mlir/lib/Dialect/AffineOps/EDSC/Builders.cpp


Index: mlir/lib/Dialect/AffineOps/EDSC/Builders.cpp
===================================================================
--- mlir/lib/Dialect/AffineOps/EDSC/Builders.cpp
+++ mlir/lib/Dialect/AffineOps/EDSC/Builders.cpp
@@ -209,11 +209,13 @@
 ValueHandle mlir::edsc::op::operator&&(ValueHandle lhs, ValueHandle rhs) {
   assert(lhs.getType().isInteger(1) && "expected boolean expression on LHS");
   assert(rhs.getType().isInteger(1) && "expected boolean expression on RHS");
-  return lhs * rhs;
+  return ValueHandle::create<AndOp>(lhs, rhs);
 }
 
 ValueHandle mlir::edsc::op::operator||(ValueHandle lhs, ValueHandle rhs) {
-  return !(!lhs && !rhs);
+  assert(lhs.getType().isInteger(1) && "expected boolean expression on LHS");
+  assert(rhs.getType().isInteger(1) && "expected boolean expression on RHS");
+  return ValueHandle::create<OrOp>(lhs, rhs);
 }
 
 static ValueHandle createIComparisonExpr(CmpIPredicate predicate,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75764.248806.patch
Type: text/x-patch
Size: 928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200306/bb734e01/attachment.bin>


More information about the llvm-commits mailing list