[PATCH] D32388: InstructionSimplify: One getShuffleMask() replacing multiple getMaskValue(). NFC.
Zvi Rackover via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 22 00:18:34 PDT 2017
zvi created this revision.
This is a preparatory step for https://reviews.llvm.org/D32338.
Repository:
rL LLVM
https://reviews.llvm.org/D32388
Files:
lib/Analysis/InstructionSimplify.cpp
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -4151,14 +4151,16 @@
if (Op0Const && Op1Const)
return ConstantFoldShuffleVectorInstruction(Op0Const, Op1Const, Mask);
+ SmallVector<int, 32> Indices;
+ ShuffleVectorInst::getShuffleMask(Mask, Indices);
+
// If only one of the operands is constant, constant fold the shuffle if the
// mask does not select elements from the variable operand.
bool MaskSelects0 = false, MaskSelects1 = false;
for (unsigned i = 0; i != MaskNumElts; ++i) {
- int Idx = ShuffleVectorInst::getMaskValue(Mask, i);
- if (Idx == -1)
+ if (Indices[i] == -1)
continue;
- if ((unsigned)Idx < InVecNumElts)
+ if ((unsigned)Indices[i] < InVecNumElts)
MaskSelects0 = true;
else
MaskSelects1 = true;
@@ -4184,9 +4186,8 @@
// Don't fold a shuffle with undef mask elements. This may get folded in a
// better way using demanded bits or other analysis.
// TODO: Should we allow this?
- for (unsigned i = 0; i != MaskNumElts; ++i)
- if (ShuffleVectorInst::getMaskValue(Mask, i) == -1)
- return nullptr;
+ if (std::find(Indices.begin(), Indices.end(), -1) != Indices.end())
+ return nullptr;
// Check if every element of this shuffle can be mapped back to the
// corresponding element of a single root vector. If so, we don't need this
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32388.96274.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170422/b2c99dfd/attachment.bin>
More information about the llvm-commits
mailing list