[PATCH] D78690: [mlir][Standard] Allow select to use an i1 for vector and tensor values

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 20:38:34 PDT 2020


rriddle created this revision.
rriddle added a reviewer: benvanik.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, mehdi_amini.
Herald added a project: LLVM.
rriddle updated this revision to Diff 259464.
rriddle added a comment.
benvanik accepted this revision.
This revision is now accepted and ready to land.

Remove unnecessary test



================
Comment at: mlir/include/mlir/Dialect/StandardOps/IR/Ops.td:1928
     // Custom form of scalar selection.
-    %x = select %cond, %true, %false : i32
+    %x = select %cond, %true, %false : i1, i32
 
----------------
I would expect that you don't need the `i1` here right? Or I misunderstand why you don't need the i1 in the "full vector selection" case below.



================
Comment at: mlir/include/mlir/Dialect/StandardOps/IR/Ops.td:1934
+    // Element-wise vector selection.
+    %vx = std.select" %vcond, %vtrue, %vfalse : vector<42xi1>, vector<42xf32>
+
----------------
It almost seems like an entirely different operation to me compared to the simple selection of one input or the other. Should we have a vselect or something?


It currently requires that the condition match the shape of the selected value, but this is only really useful for things like masks. This revision allows for the use of i1 to mean that all of the vector/tensor is selected. This also matches the behavior of LLVM select. A benefit of this change is that transformations that want to generate selects, like those on the CFG, don't have to special case vector/tensor. Previously the only way to generate  a select from an i1 was to use a splat, but that doesn't support dynamically shaped/unranked tensors.

Depends On D78683 <https://reviews.llvm.org/D78683>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78690

Files:
  mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
  mlir/lib/Dialect/StandardOps/IR/Ops.cpp
  mlir/test/Dialect/Standard/canonicalize-cf.mlir
  mlir/test/IR/core-ops.mlir
  mlir/test/IR/invalid-ops.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78690.259464.patch
Type: text/x-patch
Size: 11001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200423/be61a48b/attachment.bin>


More information about the llvm-commits mailing list