[PATCH] D63138: [Analysis] add isSplatValue() for vectors in IR

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 10:03:32 PDT 2019


spatel marked an inline comment as done.
spatel added a comment.

We have 2 text comment acknowledgements ("Seems fine", "Looks ok") - thanks for the prompt reviews!...can someone make it official by toggling the Phab state to 'Approved'? :)



================
Comment at: llvm/lib/Analysis/VectorUtils.cpp:354
+  // If all operands of a select are splats, the result is a splat.
+  if (match(V, m_Select(m_Value(X), m_Value(Y), m_Value(Z))))
+    return isSplatValue(X, Depth) && isSplatValue(Y, Depth) &&
----------------
shawnl wrote:
> We do not currently normalize vector selects to select.
> 
> see https://bugs.llvm.org/show_bug.cgi?id=41777
> 
> Should we? (as long as it doesn't require defining undefs?).
Let me know if I'm not getting the question right, but we have to be careful here to distinguish 'vector select' from 'bitwise select' (xxsel or vsel in PPC).

In IR, vector select is based on vector elements rather than bits:
http://llvm.org/docs/LangRef.html#select-instruction
(so it's more like the x86 'blend' instructions).

So to normalize to the IR vector select, we have to create something like this from a bitwise logic sequence

```
or (and x, cond), (and y, (not cond)) -->
%bitwise_cond = bitcast <4 x i32> %cond to <128 x i1>
%trueval = bitcast <4 x i32> %x to <128 x i1>
%falseval = bitcast <4 x i32> %y to <128 x i1>
%select = select <128 x i1> %bitwise_cond, <128 x i1> %trueval, <128 x i1> %falseval
%result = bitcast <128 x i1> %select to <4 x i32>
```



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

https://reviews.llvm.org/D63138





More information about the llvm-commits mailing list