summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2018-02-11 17:01:43 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2018-02-11 17:01:43 +0000
commitc2544c572af1026cd0b5da020e9506dcdd8f206c (patch)
tree0985277d42d48401c632f472f03905bf4c59f6b0 /llvm/lib
parentaee107f30dbf09a38be50d494199ca16d3adacd3 (diff)
downloadbcm5719-llvm-c2544c572af1026cd0b5da020e9506dcdd8f206c.tar.gz
bcm5719-llvm-c2544c572af1026cd0b5da020e9506dcdd8f206c.zip
[X86][SSE] Moved SplitBinaryOpsAndApply earlier so more methods can use it. NFCI.
llvm-svn: 324841
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp94
1 files changed, 47 insertions, 47 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 474142d82a0..99674f144fc 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -5048,6 +5048,53 @@ static SDValue insert256BitVector(SDValue Result, SDValue Vec, unsigned IdxVal,
return insertSubVector(Result, Vec, IdxVal, DAG, dl, 256);
}
+// 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
+// 256-bit and on AVX512BW in 512-bit.
+// The argument VT is the type used for deciding if/how to split the operands
+// Op0 and Op1. Op0 and Op1 do *not* have to be of type VT.
+// The argument Builder is a function that will be applied on each split psrt:
+// SDValue Builder(SelectionDAG&G, SDLoc, SDValue, SDValue)
+template <typename F>
+SDValue SplitBinaryOpsAndApply(SelectionDAG &DAG, const X86Subtarget &Subtarget,
+ const SDLoc &DL, EVT VT, SDValue Op0,
+ SDValue Op1, F Builder) {
+ assert(Subtarget.hasSSE2() && "Target assumed to support at least SSE2");
+ unsigned NumSubs = 1;
+ if (Subtarget.useBWIRegs()) {
+ if (VT.getSizeInBits() > 512) {
+ NumSubs = VT.getSizeInBits() / 512;
+ assert((VT.getSizeInBits() % 512) == 0 && "Illegal vector size");
+ }
+ } else if (Subtarget.hasAVX2()) {
+ if (VT.getSizeInBits() > 256) {
+ NumSubs = VT.getSizeInBits() / 256;
+ assert((VT.getSizeInBits() % 256) == 0 && "Illegal vector size");
+ }
+ } else {
+ if (VT.getSizeInBits() > 128) {
+ NumSubs = VT.getSizeInBits() / 128;
+ assert((VT.getSizeInBits() % 128) == 0 && "Illegal vector size");
+ }
+ }
+
+ if (NumSubs == 1)
+ return Builder(DAG, DL, Op0, Op1);
+
+ SmallVector<SDValue, 4> Subs;
+ EVT InVT = Op0.getValueType();
+ EVT SubVT = EVT::getVectorVT(*DAG.getContext(), InVT.getScalarType(),
+ InVT.getVectorNumElements() / NumSubs);
+ for (unsigned i = 0; i != NumSubs; ++i) {
+ unsigned Idx = i * SubVT.getVectorNumElements();
+ SDValue LHS = extractSubVector(Op0, Idx, DAG, DL, SubVT.getSizeInBits());
+ SDValue RHS = extractSubVector(Op1, Idx, DAG, DL, SubVT.getSizeInBits());
+ Subs.push_back(Builder(DAG, DL, LHS, RHS));
+ }
+ return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, Subs);
+}
+
// Return true if the instruction zeroes the unused upper part of the
// destination and accepts mask.
static bool isMaskedZeroUpperBitsvXi1(unsigned int Opcode) {
@@ -34235,53 +34282,6 @@ static SDValue combineTruncateWithSat(SDValue In, EVT VT, const SDLoc &DL,
return SDValue();
}
-// 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
-// 256-bit and on AVX512BW in 512-bit.
-// The argument VT is the type used for deciding if/how to split the operands
-// Op0 and Op1. Op0 and Op1 do *not* have to be of type VT.
-// The argument Builder is a function that will be applied on each split psrt:
-// SDValue Builder(SelectionDAG&G, SDLoc, SDValue, SDValue)
-template <typename F>
-SDValue SplitBinaryOpsAndApply(SelectionDAG &DAG, const X86Subtarget &Subtarget,
- const SDLoc &DL, EVT VT, SDValue Op0,
- SDValue Op1, F Builder) {
- assert(Subtarget.hasSSE2() && "Target assumed to support at least SSE2");
- unsigned NumSubs = 1;
- if (Subtarget.useBWIRegs()) {
- if (VT.getSizeInBits() > 512) {
- NumSubs = VT.getSizeInBits() / 512;
- assert((VT.getSizeInBits() % 512) == 0 && "Illegal vector size");
- }
- } else if (Subtarget.hasAVX2()) {
- if (VT.getSizeInBits() > 256) {
- NumSubs = VT.getSizeInBits() / 256;
- assert((VT.getSizeInBits() % 256) == 0 && "Illegal vector size");
- }
- } else {
- if (VT.getSizeInBits() > 128) {
- NumSubs = VT.getSizeInBits() / 128;
- assert((VT.getSizeInBits() % 128) == 0 && "Illegal vector size");
- }
- }
-
- if (NumSubs == 1)
- return Builder(DAG, DL, Op0, Op1);
-
- SmallVector<SDValue, 4> Subs;
- EVT InVT = Op0.getValueType();
- EVT SubVT = EVT::getVectorVT(*DAG.getContext(), InVT.getScalarType(),
- InVT.getVectorNumElements() / NumSubs);
- for (unsigned i = 0; i != NumSubs; ++i) {
- unsigned Idx = i * SubVT.getVectorNumElements();
- SDValue LHS = extractSubVector(Op0, Idx, DAG, DL, SubVT.getSizeInBits());
- SDValue RHS = extractSubVector(Op1, Idx, DAG, DL, SubVT.getSizeInBits());
- Subs.push_back(Builder(DAG, DL, LHS, RHS));
- }
- return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, Subs);
-}
-
/// This function detects the AVG pattern between vectors of unsigned i8/i16,
/// which is c = (a + b + 1) / 2, and replace this operation with the efficient
/// X86ISD::AVG instruction.
OpenPOWER on IntegriCloud