summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp46
1 files changed, 2 insertions, 44 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index ca29be097e6..c391034dc00 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -167,8 +167,7 @@ Instruction *InstCombiner::scalarizePHI(ExtractElementInst &EI, PHINode *PN) {
}
static Instruction *foldBitcastExtElt(ExtractElementInst &Ext,
- InstCombiner::BuilderTy &Builder,
- bool IsBigEndian) {
+ InstCombiner::BuilderTy &Builder) {
Value *X;
uint64_t ExtIndexC;
if (!match(Ext.getVectorOperand(), m_BitCast(m_Value(X))) ||
@@ -187,47 +186,6 @@ static Instruction *foldBitcastExtElt(ExtractElementInst &Ext,
if (Value *Elt = findScalarElement(X, ExtIndexC))
return new BitCastInst(Elt, DestTy);
- // If the source elements are wider than the destination, try to shift and
- // truncate a subset of scalar bits of an insert op.
- if (NumSrcElts < NumElts && SrcTy->getScalarType()->isIntegerTy()) {
- Value *Scalar;
- uint64_t InsIndexC;
- if (!match(X, m_InsertElement(m_Value(), m_Value(Scalar),
- m_ConstantInt(InsIndexC))))
- return nullptr;
-
- // The extract must be from the subset of vector elements that we inserted
- // into. Example: if we inserted element 1 of a <2 x i64> and we are
- // extracting an i16 (narrowing ratio = 4), then this extract must be from 1
- // of elements 4-7 of the bitcasted vector.
- unsigned NarrowingRatio = NumElts / NumSrcElts;
- if (ExtIndexC / NarrowingRatio != InsIndexC)
- return nullptr;
-
- // We are extracting part of the original scalar. How that scalar is
- // inserted into the vector depends on the endian-ness. Example:
- // Vector Byte Elt Index: 0 1 2 3 4 5 6 7
- // +--+--+--+--+--+--+--+--+
- // inselt <2 x i32> V, <i32> S, 1: |V0|V1|V2|V3|S0|S1|S2|S3|
- // extelt <4 x i16> V', 3: | |S2|S3|
- // +--+--+--+--+--+--+--+--+
- // If this is little-endian, S2|S3 are the MSB of the 32-bit 'S' value.
- // If this is big-endian, S2|S3 are the LSB of the 32-bit 'S' value.
- // In this example, we must right-shift little-endian. Big-endian is just a
- // truncate.
- unsigned Chunk = ExtIndexC % NarrowingRatio;
- if (IsBigEndian)
- Chunk = NarrowingRatio - 1 - Chunk;
- unsigned ShAmt = Chunk * DestTy->getPrimitiveSizeInBits();
- if (ShAmt) {
- // Bail out if we could end with more instructions than we started with.
- if (!Ext.getVectorOperand()->hasOneUse())
- return nullptr;
- Scalar = Builder.CreateLShr(Scalar, ShAmt);
- }
- return new TruncInst(Scalar, DestTy);
- }
-
return nullptr;
}
@@ -266,7 +224,7 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
}
}
- if (Instruction *I = foldBitcastExtElt(EI, Builder, DL.isBigEndian()))
+ if (Instruction *I = foldBitcastExtElt(EI, Builder))
return I;
// If there's a vector PHI feeding a scalar use through this extractelement
OpenPOWER on IntegriCloud