[PATCH] D77881: [VectorUtils] add IR-level analysis for widening of shuffle mask

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 15:04:41 PDT 2020


lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.


================
Comment at: llvm/lib/Analysis/VectorUtils.cpp:401
 
 void llvm::scaleShuffleMask(size_t Scale, ArrayRef<int> Mask,
                             SmallVectorImpl<int> &ScaledMask) {
----------------
As a preliminary step, rename this to be `narrowShuffleMask()` ?


================
Comment at: llvm/unittests/Analysis/VectorUtilsTest.cpp:154-155
+
+  // groups of 3 must be consecutive/undef (partial undefs are not ok)
+  EXPECT_FALSE(widenShuffleMask(3, {-1,7,8,0,-1,2,-1,-1,-1}, WideMask));
+
----------------
Oh hmm, i almost missed this. We indeed can't define `undef` shuffle mask elts here:
```
----------------------------------------
define <2 x i16> @t(<4 x i8> %x) {
%0:
  %t0 = shufflevector <4 x i8> %x, <4 x i8> undef, 4294967295, 1, 2, 3
  %t1 = bitcast <4 x i8> %t0 to <2 x i16>
  ret <2 x i16> %t1
}
=>
define <2 x i16> @t(<4 x i8> %x) {
%0:
  %t0 = bitcast <4 x i8> %x to <2 x i16>
  %t1 = shufflevector <2 x i16> %t0, <2 x i16> undef, 0, 1
  ret <2 x i16> %t1
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source

Example:
<4 x i8> %x = < poison, poison, poison, poison >

Source:
<4 x i8> %t0 = < undef, poison, poison, poison >
<2 x i16> %t1 = < #x0000 (0)    [based on undef value], poison >

Target:
<2 x i16> %t0 = < poison, poison >
<2 x i16> %t1 = < poison, poison >
Source value: < #x0000 (0), poison >
Target value: < poison, poison >

Summary:
  0 correct transformations
  1 incorrect transformations
  0 Alive2 errors

```


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

https://reviews.llvm.org/D77881





More information about the llvm-commits mailing list