[llvm] r327236 - [x86][SSE] Add widenSubVector helper. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 11 03:50:48 PDT 2018
Author: rksimon
Date: Sun Mar 11 03:50:48 2018
New Revision: 327236
URL: http://llvm.org/viewvc/llvm-project?rev=327236&view=rev
Log:
[x86][SSE] Add widenSubVector helper. NFCI.
Helper function to insert a subvector into the bottom elements of a larger zero/undef vector with the same scalar type.
I've converted a couple of INSERT_SUBVECTOR calls to use it, there are plenty more although in some cases I was worried it might make the code more ambiguous.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=327236&r1=327235&r2=327236&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Mar 11 03:50:48 2018
@@ -5081,6 +5081,20 @@ static SDValue insert256BitVector(SDValu
return insertSubVector(Result, Vec, IdxVal, DAG, dl, 256);
}
+/// Widen a vector to a larger size with the same scalar type, with the new
+/// elements either zero or undef.
+static SDValue widenSubVector(MVT VT, SDValue Vec, bool ZeroNewElements,
+ const X86Subtarget &Subtarget, SelectionDAG &DAG,
+ const SDLoc &dl) {
+ assert(Vec.getValueSizeInBits() < VT.getSizeInBits() &&
+ Vec.getValueType().getScalarType() == VT.getScalarType() &&
+ "Unsupported vector widening type");
+ SDValue Res = ZeroNewElements ? getZeroVector(VT, Subtarget, DAG, dl)
+ : DAG.getUNDEF(VT);
+ return DAG.getNode(ISD::INSERT_SUBVECTOR, dl, VT, Res, Vec,
+ DAG.getIntPtrConstant(0, dl));
+}
+
// Helper for splitting operands of a binary operation to legal target size and
// apply a function on each part.
// Useful for operations that are available on SSE2 in 128-bit, on AVX2 in
@@ -7930,9 +7944,7 @@ SDValue createVariablePermute(MVT VT, SD
if (SrcVec.getValueSizeInBits() > VT.getSizeInBits())
return SDValue();
else if (SrcVec.getValueSizeInBits() < VT.getSizeInBits())
- SrcVec =
- DAG.getNode(ISD::INSERT_SUBVECTOR, SDLoc(SrcVec), VT, DAG.getUNDEF(VT),
- SrcVec, DAG.getIntPtrConstant(0, SDLoc(SrcVec)));
+ SrcVec = widenSubVector(VT, SrcVec, false, Subtarget, DAG, SDLoc(SrcVec));
auto ScaleIndices = [&DAG](SDValue Idx, uint64_t Scale) {
assert(isPowerOf2_64(Scale) && "Illegal variable permute shuffle scale");
@@ -8612,12 +8624,8 @@ static SDValue LowerCONCAT_VECTORSvXi1(S
// of a node with instruction that zeroes all upper (irrelevant) bits of the
// output register, mark it as legal and catch the pattern in instruction
// selection to avoid emitting extra instructions (for zeroing upper bits).
- if (SDValue Promoted = isTypePromotionOfi1ZeroUpBits(Op)) {
- SDValue ZeroC = DAG.getIntPtrConstant(0, dl);
- SDValue AllZeros = getZeroVector(ResVT, Subtarget, DAG, dl);
- return DAG.getNode(ISD::INSERT_SUBVECTOR, dl, ResVT, AllZeros, Promoted,
- ZeroC);
- }
+ if (SDValue Promoted = isTypePromotionOfi1ZeroUpBits(Op))
+ return widenSubVector(ResVT, Promoted, true, Subtarget, DAG, dl);
unsigned NumZero = 0;
unsigned NumNonZero = 0;
More information about the llvm-commits
mailing list