[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-03-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

(Also merged followup 
https://github.com/llvm/llvm-project/commit/ba4764c2cc14b0b495af539a913de10cf8268420
 to fix a memory leak caught by the bots.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-03-27 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

Looks like D76649  landed and added another 
IRBuilder call that needs updating:

  [2974/5437] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86PartialReduction.cpp.o
  FAILED: 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86PartialReduction.cpp.o 
  CCACHE_DIR=/mnt/disks/ssd0/ccache CCACHE_MAXSIZE=20G CCACHE_CPP2=yes 
CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++  -DGTEST_HAS_RTTI=0 
-D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Ilib/Target/X86 
-I/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/llvm/lib/Target/X86
 -I/usr/include/libxml2 -Iinclude 
-I/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/llvm/include 
-gmlt -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default 
-Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
-Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3 
 -fvisibility=hidden-fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86PartialReduction.cpp.o -MF 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86PartialReduction.cpp.o.d -o 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86PartialReduction.cpp.o -c 
/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/llvm/lib/Target/X86/X86PartialReduction.cpp
  
/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/llvm/lib/Target/X86/X86PartialReduction.cpp:387:22:
 error: call to member function 'CreateShuffleVector' is ambiguous
  Ops[0] = Builder.CreateShuffleVector(Ops[0], Ops[0], {0, 1});
   ^~~
  
/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/llvm/include/llvm/IR/IRBuilder.h:2625:10:
 note: candidate function
Value *CreateShuffleVector(Value *V1, Value *V2, ArrayRef Mask,
   ^
  
/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/llvm/include/llvm/IR/IRBuilder.h:2633:10:
 note: candidate function
Value *CreateShuffleVector(Value *V1, Value *V2, ArrayRef Mask,
   ^
  
/mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/llvm/include/llvm/IR/IRBuilder.h:2618:10:
 note: candidate function not viable: cannot convert initializer list argument 
to 'llvm::Value *'
Value *CreateShuffleVector(Value *V1, Value *V2, Value *Mask,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 241333.
efriedma added a comment.

Address review comments, rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467

Files:
  clang/lib/CodeGen/CGExpr.cpp
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/Analysis/ConstantFolding.h
  llvm/include/llvm/Analysis/InstructionSimplify.h
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/ConstantFold.h
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/ConstantsContext.h
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
  llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/MVETailPredication.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/GVNSink.cpp
  llvm/lib/Transforms/Scalar/NewGVN.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/IR/PatternMatch.cpp

Index: llvm/unittests/IR/PatternMatch.cpp
===
--- llvm/unittests/IR/PatternMatch.cpp
+++ llvm/unittests/IR/PatternMatch.cpp
@@ -991,31 +991,31 @@
   EXPECT_TRUE(match(EX3, m_ExtractElement(m_Constant(), m_ConstantInt(;
 
   // Test matching shufflevector
-  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_Zero(;
-  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Value(C;
+  ArrayRef Mask;
+  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_ZeroMask(;
+  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Mask(Mask;
   EXPECT_TRUE(A == VI3);
   EXPECT_TRUE(B == VI4);
-  EXPECT_TRUE(C == IdxVec);
   A = B = C = nullptr; // reset
 
   // Test matching the vector splat pattern
   EXPECT_TRUE(match(
   SI1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(1), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI3, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI4, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(2), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP2, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(A), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(A == Val);
 }
 
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3399,7 +3399,7 @@
 auto *O1 = B.CreateZExtOrTrunc(
 SI->getOperand(1), VectorType::get(ScalarTruncatedTy, Elements1));
 
-NewI = B.CreateShuffleVector(O0, O1, SI->getMask());
+NewI = B.CreateShuffleVector(O0, O1, SI->getShuffleMask());
   } else if (isa(I) || isa(I)) {
 // Don't do anything with the operands, just extend the result.
 continue;
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-24 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D72467#1839172 , @efriedma wrote:

> In D72467#1838591 , @spatel wrote:
>
> > LGTM, but should get a 2nd opinion since I'm not familiar with some of the 
> > parts.
>
>
> Any specific part you're worried about?


I don't know anything about the scalable vector enhancements, but that seems 
covered now. Nuances of the bitcode serialization are beyond me, but I trust 
you've stepped through that. So, no worries. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma marked 5 inline comments as done.
efriedma added a comment.

In D72467#1838591 , @spatel wrote:

> LGTM, but should get a 2nd opinion since I'm not familiar with some of the 
> parts.


Any specific part you're worried about?




Comment at: llvm/include/llvm/IR/Instructions.h:1980
 
+constexpr int UndefMaskElem = -1;
+

sdesmalen wrote:
> nit: do we want to make this a member of ShuffleVectorInst, as this is likely 
> the only context in which it will be used?
ShuffleVectorInst::UndefMaskElem is sort of long. Maybe we don't use it in 
enough places to matter.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:3597
 
-  if (MaskV->isNullValue() && VT.isScalableVector()) {
+  if (all_of(Mask, [](int Elem) { return Elem == 0; }) &&
+  VT.isScalableVector()) {

sdesmalen wrote:
> Should this use `m_ZeroMask()` ?
I don't want to make unrelated functional changes in this patch.



Comment at: llvm/lib/IR/ConstantFold.cpp:870
   // Undefined shuffle mask -> undefined value.
-  if (isa(Mask))
+  if (all_of(Mask, [](int Elt) { return Elt == UndefMaskElem; }))
 return UndefValue::get(VectorType::get(EltTy, MaskNumElts));

sdesmalen wrote:
> Is it worth adding a `m_UndefMask` ?
We currently only use this pattern in three places, and I doubt we're going to 
add more.



Comment at: llvm/lib/IR/Constants.cpp:2260
+  Constant *ArgVec[] = { V1, V2 };
+  ConstantExprKeyType Key(Instruction::ShuffleVector, ArgVec, 0, 0, None, 
Mask);
 

sdesmalen wrote:
> nit: is there a reason for dropping `const` here?
Doesn't really matter either way, but we generally don't add const markings to 
local variables just because we can.



Comment at: llvm/lib/IR/ConstantsContext.h:153
cast(C1->getType())->getElementType(),
-   cast(C3->getType())->getElementCount()),
+   Mask.size(), C1->getType()->getVectorIsScalable()),
  Instruction::ShuffleVector,

ctetreau wrote:
> sdesmalen wrote:
> > The number of elements in the result matches the number of elements in the 
> > mask, but if we assume 'scalable' from one of the source vectors, this 
> > means we make the choice that we cannot extract a fixed-width vector from a 
> > scalable vector, e.g.
> > 
> >   shufflevector( %in,  undef, <4 x i32> 
> > )
> > 
> > The LangRef does not explicitly call out this case (and it currently fails 
> > to compile), but it would provide a way to extract a sub-vector from a 
> > scalable vector.
> > If we want to allow this, we'd also need to decide what the meaning would 
> > be of:
> > 
> >   shufflevector( %in,  undef, <4 x i32> 
> > )
> > 
> > which may not be valid if `vscale = 1`.
> > 
> > Alternatively, we could implement this with an additional extract intrinsic 
> > and add the restriction that if the source values are scalable, the mask 
> > must be scalable as well. If so, then we should update the LangRef to 
> > explicitly disallow the above case.
> For the time being, Either this assumption must hold, or a bool must be added 
> that is true if the mask is from a scalable vector.
> 
> There are places in the codebase that assume that the mask has a concrete 
> value known at compile time. These sites are currently the sites of bugs, and 
> the fix is to not try to access the mask if the vector is scalable. We need 
> some way of knowing that the mask is scalable, either by the assumption made 
> here, or a queryable bool value.
I'd prefer to just say the result is scalable if and only if the operand is 
scalable, at least for now.  It's not clear what semantics we want for a fixed 
shuffle of a scalable operand, and allowing scalable splats of fixed vectors 
doesn't really allow expressing anything new.  We can relax it later once we've 
settled on our general approach to scalable shuffles.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-24 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added inline comments.



Comment at: llvm/lib/IR/ConstantsContext.h:153
cast(C1->getType())->getElementType(),
-   cast(C3->getType())->getElementCount()),
+   Mask.size(), C1->getType()->getVectorIsScalable()),
  Instruction::ShuffleVector,

sdesmalen wrote:
> The number of elements in the result matches the number of elements in the 
> mask, but if we assume 'scalable' from one of the source vectors, this means 
> we make the choice that we cannot extract a fixed-width vector from a 
> scalable vector, e.g.
> 
>   shufflevector( %in,  undef, <4 x i32> 
> )
> 
> The LangRef does not explicitly call out this case (and it currently fails to 
> compile), but it would provide a way to extract a sub-vector from a scalable 
> vector.
> If we want to allow this, we'd also need to decide what the meaning would be 
> of:
> 
>   shufflevector( %in,  undef, <4 x i32> 
> )
> 
> which may not be valid if `vscale = 1`.
> 
> Alternatively, we could implement this with an additional extract intrinsic 
> and add the restriction that if the source values are scalable, the mask must 
> be scalable as well. If so, then we should update the LangRef to explicitly 
> disallow the above case.
For the time being, Either this assumption must hold, or a bool must be added 
that is true if the mask is from a scalable vector.

There are places in the codebase that assume that the mask has a concrete value 
known at compile time. These sites are currently the sites of bugs, and the fix 
is to not try to access the mask if the vector is scalable. We need some way of 
knowing that the mask is scalable, either by the assumption made here, or a 
queryable bool value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

Thanks @efriedma for working on this. The overall approach seems good to me!
Mostly added some nits, with the exception of one question on what to do with a 
shufflevector with fixed-width mask and scalable source vectors.




Comment at: llvm/include/llvm/IR/Instructions.h:1980
 
+constexpr int UndefMaskElem = -1;
+

nit: do we want to make this a member of ShuffleVectorInst, as this is likely 
the only context in which it will be used?



Comment at: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:2694
 pushValue(I.getOperand(1), InstID, Vals);
-pushValue(I.getOperand(2), InstID, Vals);
+pushValue(cast(I).getShuffleMaskForBitcode(), InstID, 
Vals);
 break;

nit: >80char (please run through clang-format)



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:3597
 
-  if (MaskV->isNullValue() && VT.isScalableVector()) {
+  if (all_of(Mask, [](int Elem) { return Elem == 0; }) &&
+  VT.isScalableVector()) {

Should this use `m_ZeroMask()` ?



Comment at: llvm/lib/IR/ConstantFold.cpp:870
   // Undefined shuffle mask -> undefined value.
-  if (isa(Mask))
+  if (all_of(Mask, [](int Elt) { return Elt == UndefMaskElem; }))
 return UndefValue::get(VectorType::get(EltTy, MaskNumElts));

Is it worth adding a `m_UndefMask` ?



Comment at: llvm/lib/IR/Constants.cpp:2260
+  Constant *ArgVec[] = { V1, V2 };
+  ConstantExprKeyType Key(Instruction::ShuffleVector, ArgVec, 0, 0, None, 
Mask);
 

nit: is there a reason for dropping `const` here?



Comment at: llvm/lib/IR/ConstantsContext.h:153
cast(C1->getType())->getElementType(),
-   cast(C3->getType())->getElementCount()),
+   Mask.size(), C1->getType()->getVectorIsScalable()),
  Instruction::ShuffleVector,

The number of elements in the result matches the number of elements in the 
mask, but if we assume 'scalable' from one of the source vectors, this means we 
make the choice that we cannot extract a fixed-width vector from a scalable 
vector, e.g.

  shufflevector( %in,  undef, <4 x i32> 
)

The LangRef does not explicitly call out this case (and it currently fails to 
compile), but it would provide a way to extract a sub-vector from a scalable 
vector.
If we want to allow this, we'd also need to decide what the meaning would be of:

  shufflevector( %in,  undef, <4 x i32> 
)

which may not be valid if `vscale = 1`.

Alternatively, we could implement this with an additional extract intrinsic and 
add the restriction that if the source values are scalable, the mask must be 
scalable as well. If so, then we should update the LangRef to explicitly 
disallow the above case.



Comment at: llvm/lib/IR/ConstantsContext.h:470
 struct ConstantExprKeyType {
+private:
   uint8_t Opcode;

nit: make ConstantExprKeyType a `class`?



Comment at: llvm/lib/IR/Instructions.cpp:1948
+  ShuffleMaskForBitcode = convertShuffleMaskForBitcode(Mask, getType());
+
+}

nit: odd newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-24 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM, but should get a 2nd opinion since I'm not familiar with some of the 
parts.
Also, please update the related LangRef text for shufflevector in or alongside 
this patch.

Could add some ascii art to visualize the mask indexing as requested by 
@ctetreau ?

  shufflevector <3 x float> %x, <3 x float> %y,  %mask:
  +---+---+---+---+---+---+
  | x | y |  vector operands
  +---+---+---+---+---+---+
  | 0 | 1 | 2 | 0 | 1 | 2 |  per-operand indexing
  +---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 |  shuffle mask indexing
  +---+---+---+---+---+---+




Comment at: llvm/include/llvm/IR/Instructions.h:2039
   /// Return the shuffle mask value of this instruction for the given element
   /// index. Return -1 if the element is undef.
   int getMaskValue(unsigned Elt) const {

Can replace the magic -1 with the named "UndefMaskElem" in this comment.



Comment at: llvm/include/llvm/IR/Instructions.h:2050
   /// Return the mask for this instruction as a vector of integers. Undefined
   /// elements of the mask are returned as -1.
   void getShuffleMask(SmallVectorImpl ) const {

Can replace the magic -1 with the named "UndefMaskElem" in this comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-23 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 240071.
efriedma added a comment.

Addressed review comments.  Rebased.

Chris Tetreault mentioned offline that we might want to change the return value 
of `getShuffleMask()` now, to try to save some work later when we add more 
forms of scalable vector shuffle.  (Not actually changing the functionality of 
any code, just pre-emptively changing the types so we don't have to change code 
again if it doesn't actually examine the shuffle mask directly.)  I'll look 
into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467

Files:
  clang/lib/CodeGen/CGExpr.cpp
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/Analysis/ConstantFolding.h
  llvm/include/llvm/Analysis/InstructionSimplify.h
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/ConstantFold.h
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/ConstantsContext.h
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
  llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/MVETailPredication.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/GVNSink.cpp
  llvm/lib/Transforms/Scalar/NewGVN.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/IR/PatternMatch.cpp

Index: llvm/unittests/IR/PatternMatch.cpp
===
--- llvm/unittests/IR/PatternMatch.cpp
+++ llvm/unittests/IR/PatternMatch.cpp
@@ -991,31 +991,31 @@
   EXPECT_TRUE(match(EX3, m_ExtractElement(m_Constant(), m_ConstantInt(;
 
   // Test matching shufflevector
-  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_Zero(;
-  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Value(C;
+  ArrayRef Mask;
+  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_ZeroMask(;
+  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Mask(Mask;
   EXPECT_TRUE(A == VI3);
   EXPECT_TRUE(B == VI4);
-  EXPECT_TRUE(C == IdxVec);
   A = B = C = nullptr; // reset
 
   // Test matching the vector splat pattern
   EXPECT_TRUE(match(
   SI1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(1), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI3, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI4, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(2), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP2, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(A), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(A == Val);
 }
 
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3400,7 +3400,7 @@
 auto *O1 = 

[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-23 Thread Eli Friedman via Phabricator via cfe-commits
efriedma marked 5 inline comments as done.
efriedma added inline comments.



Comment at: llvm/include/llvm/IR/IRBuilder.h:2551
+SmallVector IntMask;
+IntMask.assign(Mask.begin(), Mask.end());
+return CreateShuffleVector(V1, V2, IntMask, Name);

ctetreau wrote:
> [0 .. uint32_MAX] is wider than [0 .. int_MAX]. Assert the values are in 
> range somehow?
Either the resulting shuffle mask is invalid (and we'll assert later), or the 
input contained UINT_MAX, in which case we'll treat it as undef.



Comment at: llvm/include/llvm/IR/Instructions.h:2015
 
-  // allocate space for exactly three operands
+  // allocate space for exactly two operands
   void *operator new(size_t s) {

spatel wrote:
> This comment doesn't add value to me, so I'd just delete it. If we want to 
> keep it, should fix it to be a proper sentence with a capital letter and 
> period.
I think the comment is there to identify the magic number.  Maybe I should 
introduce a named constant ShuffleVectorInst::NumOperands to make that clear.



Comment at: llvm/include/llvm/IR/PatternMatch.h:1306
+
+struct m_ZeroMask {
+  bool match(ArrayRef Mask) {

spatel wrote:
> IIUC, this is meant to replace the current uses of m_Zero() or m_ZeroInt() 
> with shuffle pattern matching, but there's a logic difference because those 
> matchers allow undefs, but this does not? Are we missing unittests to catch 
> that case?
I guess we're missing tests, yes; I didn't see any failures.



Comment at: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1890
   for( unsigned i=0; i I've never looked in here before - what happens currently if the index is -1 
> (undef)?
The interpreter evaluates undef to zero, and therefore it behaves as if every 
undef is replaced with zero.

Using std::max here preserves the existing behavior.



Comment at: llvm/lib/IR/ConstantsContext.h:564
 case Instruction::ShuffleVector:
-  return new ShuffleVectorConstantExpr(Ops[0], Ops[1], Ops[2]);
+  return new ShuffleVectorConstantExpr(Ops[0], Ops[1], Indexes);
 case Instruction::InsertValue:

spatel wrote:
> (not familiar with this part)
> If we're using Indexes here, do we need to update the code/comments for 
> hasIndices()?
> 
>   /// Return true if this is an insertvalue or extractvalue expression,
>   /// and the getIndices() method may be used.
As part of constructing ConstantExprs, there's a map from ConstantExprKeyType 
to ConstantExpr, to ensure each expression is unique.  "Indexes" is just a list 
of integers, so I was reusing it as a shortcut, to try to avoid making an extra 
ArrayRef.  This only impacts the map itself, not the final ConstantExprs.

It looks like I missed that a few places use `hasIndices()` to check whether 
the ConstantExprKeyType key stores data in Indexes.  I should probably just add 
the extra member variable to make the logic clear, even if it wastes a tiny bit 
of stack space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-23 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added inline comments.



Comment at: llvm/include/llvm/IR/IRBuilder.h:2544
+SmallVector IntMask;
+ShuffleVectorInst::getShuffleMask(cast(Mask), IntMask);
+return CreateShuffleVector(V1, V2, IntMask, Name);

spatel wrote:
> Add an assert that Mask isa ?
cast already does this assert.



Comment at: llvm/include/llvm/IR/IRBuilder.h:2551
+SmallVector IntMask;
+IntMask.assign(Mask.begin(), Mask.end());
+return CreateShuffleVector(V1, V2, IntMask, Name);

[0 .. uint32_MAX] is wider than [0 .. int_MAX]. Assert the values are in range 
somehow?



Comment at: llvm/include/llvm/IR/Instructions.h:1985-1986
 ///
+/// The shuffle mask operand specifies, for each element of the result vector,
+/// which element of the two input vectors the result element gets. The
+/// shuffle mask is represented as an array of integers. Positive integers

spatel wrote:
> This reads awkwardly to me (if you agree, we can update the LangRef too). 
> How about:
> "For each element of the result vector, the shuffle mask selects an element 
> from one of the input vectors to copy to the result. Non-negative elements in 
> the mask represent an index into the concatenated pair of input vectors. 
> UndefMaskElem (-1) specifies that the result element is undefined."
I also found the wording of the description of shufflevector in the language 
ref confusing. Since this description seems to be related I thought it worth 
mentioning.

It's unclear to me how the values specify vector inputs. I assume for two 
vectors <4 x 18>, that the mask <3, 4, 5, 6> takes the last element of the 
first vector, and the first three elements of the second vector, but this isn't 
explicitly stated anywhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-23 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added inline comments.



Comment at: llvm/include/llvm/IR/Constants.h:1220
 
+  /// Assert that this is an shufflevector and return the mask. See class
+  /// ShuffleVectorInst for a description of the mask representation.

an shufflevector -> a shufflevector



Comment at: llvm/include/llvm/IR/Constants.h:1224
+
+  /// Assert that this is an shufflevector and return the mask.
+  ///

an shufflevector -> a shufflevector



Comment at: llvm/include/llvm/IR/IRBuilder.h:2544
+SmallVector IntMask;
+ShuffleVectorInst::getShuffleMask(cast(Mask), IntMask);
+return CreateShuffleVector(V1, V2, IntMask, Name);

Add an assert that Mask isa ?



Comment at: llvm/include/llvm/IR/Instructions.h:1985-1986
 ///
+/// The shuffle mask operand specifies, for each element of the result vector,
+/// which element of the two input vectors the result element gets. The
+/// shuffle mask is represented as an array of integers. Positive integers

This reads awkwardly to me (if you agree, we can update the LangRef too). 
How about:
"For each element of the result vector, the shuffle mask selects an element 
from one of the input vectors to copy to the result. Non-negative elements in 
the mask represent an index into the concatenated pair of input vectors. 
UndefMaskElem (-1) specifies that the result element is undefined."



Comment at: llvm/include/llvm/IR/Instructions.h:2015
 
-  // allocate space for exactly three operands
+  // allocate space for exactly two operands
   void *operator new(size_t s) {

This comment doesn't add value to me, so I'd just delete it. If we want to keep 
it, should fix it to be a proper sentence with a capital letter and period.



Comment at: llvm/include/llvm/IR/PatternMatch.h:1306
+
+struct m_ZeroMask {
+  bool match(ArrayRef Mask) {

IIUC, this is meant to replace the current uses of m_Zero() or m_ZeroInt() with 
shuffle pattern matching, but there's a logic difference because those matchers 
allow undefs, but this does not? Are we missing unittests to catch that case?



Comment at: llvm/include/llvm/IR/PatternMatch.h:1320
+
 /// Matches ShuffleVectorInst.
+template 

Update/add comment:
"Matches ShuffleVectorInst independently of mask value." ?



Comment at: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:937-939
+   if (auto *CE = dyn_cast(C))
+ if (CE->getOpcode() == Instruction::ShuffleVector)
+   EnumerateOperandType(CE->getShuffleMaskForBitcode());

Indentation looks off-by-1.



Comment at: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:1937
+  ArrayRef Mask;
+  if (const ShuffleVectorInst *SVI = dyn_cast())
+Mask = SVI->getShuffleMask();

if (auto *SVI = ...)



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:3587
+  ArrayRef Mask;
+  if (const ShuffleVectorInst *SVI = dyn_cast())
+Mask = SVI->getShuffleMask();

if (auto *SVI = ...)



Comment at: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1890
   for( unsigned i=0; igetSyncScopeID() == cast(I2)->getSyncScopeID();
+  if (const ShuffleVectorInst *SVI = dyn_cast(I1))
+return SVI->getShuffleMask() == 
cast(I2)->getShuffleMask();

Would have suggested "auto *" here, but really the whole thing should be turned 
into a switch() as a preliminary cleanup?



Comment at: llvm/lib/IR/Instructions.cpp:1824-1825
+ Instruction *InsertBefore)
+: 
Instruction(VectorType::get(cast(V1->getType())->getElementType(),
+Mask.size(), V1->getType()->getVectorIsScalable()),
+  ShuffleVector,

I see this is copied, but indentation seems off.



Comment at: llvm/lib/Transforms/Scalar/GVN.cpp:304
   e.varargs.push_back(*II);
+  } else if (ShuffleVectorInst *SVI = dyn_cast(I)) {
+ArrayRef ShuffleMask = SVI->getShuffleMask();

Use "auto *" in each clause (or convert to switch).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 237830.
efriedma edited the summary of this revision.
efriedma added a comment.

Fixed one more issue.  While I'm at it, get rid of the old overload of 
ConstantExpr::getShuffleVector, which only had a few remaining uses.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467

Files:
  clang/lib/CodeGen/CGExpr.cpp
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/Analysis/ConstantFolding.h
  llvm/include/llvm/Analysis/InstructionSimplify.h
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/ConstantFold.h
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/ConstantsContext.h
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
  llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/MVETailPredication.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/GVNSink.cpp
  llvm/lib/Transforms/Scalar/NewGVN.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/IR/PatternMatch.cpp

Index: llvm/unittests/IR/PatternMatch.cpp
===
--- llvm/unittests/IR/PatternMatch.cpp
+++ llvm/unittests/IR/PatternMatch.cpp
@@ -991,31 +991,31 @@
   EXPECT_TRUE(match(EX3, m_ExtractElement(m_Constant(), m_ConstantInt(;
 
   // Test matching shufflevector
-  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_Zero(;
-  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Value(C;
+  ArrayRef Mask;
+  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_ZeroMask(;
+  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Mask(Mask;
   EXPECT_TRUE(A == VI3);
   EXPECT_TRUE(B == VI4);
-  EXPECT_TRUE(C == IdxVec);
   A = B = C = nullptr; // reset
 
   // Test matching the vector splat pattern
   EXPECT_TRUE(match(
   SI1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(1), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI3, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI4, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(2), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP2, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(A), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(A == Val);
 }
 
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3399,7 +3399,7 @@
 auto *O1 = B.CreateZExtOrTrunc(
 SI->getOperand(1), VectorType::get(ScalarTruncatedTy, Elements1));
 
-NewI = B.CreateShuffleVector(O0, O1, SI->getMask());
+NewI = B.CreateShuffleVector(O0, O1, SI->getShuffleMask());
   } else if (isa(I) || isa(I)) {
 

[PATCH] D72467: Remove "mask" operand from shufflevector.

2020-01-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 237825.
efriedma retitled this revision from "[WIP] Remove "mask" operand from 
shufflevector." to "Remove "mask" operand from shufflevector.".
efriedma added a comment.

Rebase.  Address review comment.  More work on bitcode.

I probably need to come up with some testcases for the bitcode encode/decode; 
we currently don't have great coverage.  Otherwise, I think this patch is 
complete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72467

Files:
  clang/lib/CodeGen/CGExpr.cpp
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/Analysis/ConstantFolding.h
  llvm/include/llvm/Analysis/InstructionSimplify.h
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/ConstantFold.h
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/ConstantsContext.h
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
  llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/MVETailPredication.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/GVN.cpp
  llvm/lib/Transforms/Scalar/GVNSink.cpp
  llvm/lib/Transforms/Scalar/NewGVN.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/IR/PatternMatch.cpp

Index: llvm/unittests/IR/PatternMatch.cpp
===
--- llvm/unittests/IR/PatternMatch.cpp
+++ llvm/unittests/IR/PatternMatch.cpp
@@ -991,31 +991,31 @@
   EXPECT_TRUE(match(EX3, m_ExtractElement(m_Constant(), m_ConstantInt(;
 
   // Test matching shufflevector
-  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_Zero(;
-  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Value(C;
+  ArrayRef Mask;
+  EXPECT_TRUE(match(SI1, m_ShuffleVector(m_Value(), m_Undef(), m_ZeroMask(;
+  EXPECT_TRUE(match(SI2, m_ShuffleVector(m_Value(A), m_Value(B), m_Mask(Mask;
   EXPECT_TRUE(A == VI3);
   EXPECT_TRUE(B == VI4);
-  EXPECT_TRUE(C == IdxVec);
   A = B = C = nullptr; // reset
 
   // Test matching the vector splat pattern
   EXPECT_TRUE(match(
   SI1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(1), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI3, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_FALSE(match(
   SI4, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP1,
   m_ShuffleVector(m_InsertElement(m_Undef(), m_SpecificInt(2), m_Zero()),
-  m_Undef(), m_Zero(;
+  m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(match(
   SP2, m_ShuffleVector(m_InsertElement(m_Undef(), m_Value(A), m_Zero()),
-   m_Undef(), m_Zero(;
+   m_Undef(), m_ZeroMask(;
   EXPECT_TRUE(A == Val);
 }
 
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3399,7 +3399,7 @@
 auto *O1 = B.CreateZExtOrTrunc(
 SI->getOperand(1), VectorType::get(ScalarTruncatedTy, Elements1));
 
-NewI = B.CreateShuffleVector(O0, O1,