Skip to content

Commit 64a9ae4

Browse files
committed
Fix formatting
1 parent f36fe7c commit 64a9ae4

File tree

2 files changed

+105
-146
lines changed

2 files changed

+105
-146
lines changed

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4065,7 +4065,6 @@ SDValue AMDGPUTargetLowering::splitBinaryBitConstantOpImpl(
40654065
// scalarises the AND for this optimisation case.
40664066
static SDValue getShiftForReduction(unsigned ShiftOpc, SDValue LHS, SDValue RHS,
40674067
SelectionDAG &DAG) {
4068-
40694068
assert(
40704069
(ShiftOpc == ISD::SRA || ShiftOpc == ISD::SRL || ShiftOpc == ISD::SHL) &&
40714070
"Expected shift Opcode.");

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 105 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -13372,7 +13372,6 @@ SDValue SITargetLowering::performXorCombine(SDNode *N,
1337213372
// v2i32 (xor (vselect cc, x, y), K) ->
1337313373
// (v2i32 svelect cc, (xor x, K), (xor y, K)) This enables the xor to be
1337413374
// replaced with source modifiers when the select is lowered to CNDMASK.
13375-
// TODO REMOVE: prevents regressions in fneg-modifier-casting.ll
1337613375
unsigned Opc = LHS.getOpcode();
1337713376
if(((Opc == ISD::VSELECT && VT==MVT::v2i32) || (Opc == ISD::SELECT && VT==MVT::i64)) && CRHS && CRHS->getAPIntValue().isSignMask()) {
1337813377
SDValue CC = LHS->getOperand(0);
@@ -14350,165 +14349,126 @@ bool SITargetLowering::shouldExpandVectorDynExt(SDNode *N) const {
1435014349
EltSize, NumElem, Idx->isDivergent(), getSubtarget());
1435114350
}
1435214351

14353-
// SDValue
14354-
// SITargetLowering::performBuildVectorCombine(SDNode *N,
14355-
// DAGCombinerInfo &DCI) const {
14356-
// // if (N->use_empty())
14357-
// // return SDValue();
14358-
14359-
// // if(!N->getValueType(0).isFloatingPoint())
14360-
// // return SDValue();
14361-
14362-
// // SelectionDAG &DAG = DCI.DAG;
14363-
14364-
// // // Iterate the operands. Check if source modifier. If so, propogate the
14365-
// // source
14366-
// // // modifier to the user and the srcmod from the BUILD_VECTOR element.
14367-
// // for (unsigned I = 0; I < N->getNumOperands(); I++) {
14368-
// // SDValue E = N->getOperand(I);
14369-
// // if (E->getOpcode() != ISD::FNEG && E->getOpcode() != ISD::ABS)
14370-
// // continue;
14371-
14372-
// // // Users through which we can propogate will include users of
14373-
// // // extract_element on this vector, so need to peek-through.
14374-
// // }
14375-
14376-
// // SmallVector<SDNode*, 4> UsersToModify;
14377-
14378-
// // // If the use of the BUILD_VECTOR supports source mods it can be
14379-
// // propogated. for (SDNode *U : N->users()) {
14380-
// // if(!U->getOpcode() == ISD::EXTRACT_VECTOR_ELT)
14381-
// // if (!allUsesHaveSourceMods(U))
14382-
// // continue;
14383-
// // UsersToModify.push_back(U);
14384-
// // }
14385-
14386-
// // for(auto Node: UsersToModify) {
14387-
14388-
// // }
14389-
14390-
// return SDValue();
14391-
// }
14392-
14393-
SDValue SITargetLowering::performExtractVectorEltCombine(
14394-
SDNode * N, DAGCombinerInfo & DCI) const {
14395-
SDValue Vec = N->getOperand(0);
14396-
SelectionDAG &DAG = DCI.DAG;
14397-
14398-
EVT VecVT = Vec.getValueType();
14399-
EVT VecEltVT = VecVT.getVectorElementType();
14400-
EVT ResVT = N->getValueType(0);
14352+
SDValue
14353+
SITargetLowering::performExtractVectorEltCombine(SDNode *N,
14354+
DAGCombinerInfo &DCI) const {
14355+
SDValue Vec = N->getOperand(0);
14356+
SelectionDAG &DAG = DCI.DAG;
1440114357

14402-
unsigned VecSize = VecVT.getSizeInBits();
14403-
unsigned VecEltSize = VecEltVT.getSizeInBits();
14358+
EVT VecVT = Vec.getValueType();
14359+
EVT VecEltVT = VecVT.getVectorElementType();
14360+
EVT ResVT = N->getValueType(0);
1440414361

14405-
if ((Vec.getOpcode() == ISD::FNEG || Vec.getOpcode() == ISD::FABS) &&
14406-
allUsesHaveSourceMods(N)) {
14407-
SDLoc SL(N);
14408-
SDValue Idx = N->getOperand(1);
14409-
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14410-
Vec.getOperand(0), Idx);
14411-
return DAG.getNode(Vec.getOpcode(), SL, ResVT, Elt);
14412-
}
14413-
14414-
// ScalarRes = EXTRACT_VECTOR_ELT ((vector-BINOP Vec1, Vec2), Idx)
14415-
// =>
14416-
// Vec1Elt = EXTRACT_VECTOR_ELT(Vec1, Idx)
14417-
// Vec2Elt = EXTRACT_VECTOR_ELT(Vec2, Idx)
14418-
// ScalarRes = scalar-BINOP Vec1Elt, Vec2Elt
14419-
if (Vec.hasOneUse() && DCI.isBeforeLegalize() && VecEltVT == ResVT) {
14420-
SDLoc SL(N);
14421-
SDValue Idx = N->getOperand(1);
14422-
unsigned Opc = Vec.getOpcode();
14362+
unsigned VecSize = VecVT.getSizeInBits();
14363+
unsigned VecEltSize = VecEltVT.getSizeInBits();
1442314364

14424-
switch (Opc) {
14425-
default:
14426-
break;
14427-
// TODO: Support other binary operations.
14428-
case ISD::FADD:
14429-
case ISD::FSUB:
14430-
case ISD::FMUL:
14431-
case ISD::ADD:
14432-
case ISD::UMIN:
14433-
case ISD::UMAX:
14434-
case ISD::SMIN:
14435-
case ISD::SMAX:
14436-
case ISD::FMAXNUM:
14437-
case ISD::FMINNUM:
14438-
case ISD::FMAXNUM_IEEE:
14439-
case ISD::FMINNUM_IEEE:
14440-
case ISD::FMAXIMUM:
14441-
case ISD::FMINIMUM: {
14442-
SDValue Elt0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14443-
Vec.getOperand(0), Idx);
14444-
SDValue Elt1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14445-
Vec.getOperand(1), Idx);
14446-
14447-
DCI.AddToWorklist(Elt0.getNode());
14448-
DCI.AddToWorklist(Elt1.getNode());
14449-
return DAG.getNode(Opc, SL, ResVT, Elt0, Elt1, Vec->getFlags());
14450-
}
14451-
}
14452-
}
14365+
if ((Vec.getOpcode() == ISD::FNEG || Vec.getOpcode() == ISD::FABS) &&
14366+
allUsesHaveSourceMods(N)) {
14367+
SDLoc SL(N);
14368+
SDValue Idx = N->getOperand(1);
14369+
SDValue Elt =
14370+
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec.getOperand(0), Idx);
14371+
return DAG.getNode(Vec.getOpcode(), SL, ResVT, Elt);
14372+
}
14373+
14374+
// ScalarRes = EXTRACT_VECTOR_ELT ((vector-BINOP Vec1, Vec2), Idx)
14375+
// =>
14376+
// Vec1Elt = EXTRACT_VECTOR_ELT(Vec1, Idx)
14377+
// Vec2Elt = EXTRACT_VECTOR_ELT(Vec2, Idx)
14378+
// ScalarRes = scalar-BINOP Vec1Elt, Vec2Elt
14379+
if (Vec.hasOneUse() && DCI.isBeforeLegalize() && VecEltVT == ResVT) {
14380+
SDLoc SL(N);
14381+
SDValue Idx = N->getOperand(1);
14382+
unsigned Opc = Vec.getOpcode();
1445314383

14454-
// EXTRACT_VECTOR_ELT (<n x e>, var-idx) => n x select (e, const-idx)
14455-
if (shouldExpandVectorDynExt(N)) {
14456-
SDLoc SL(N);
14457-
SDValue Idx = N->getOperand(1);
14458-
SDValue V;
14459-
for (unsigned I = 0, E = VecVT.getVectorNumElements(); I < E; ++I) {
14460-
SDValue IC = DAG.getVectorIdxConstant(I, SL);
14461-
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec, IC);
14462-
if (I == 0)
14463-
V = Elt;
14464-
else
14465-
V = DAG.getSelectCC(SL, Idx, IC, Elt, V, ISD::SETEQ);
14466-
}
14467-
return V;
14384+
switch (Opc) {
14385+
default:
14386+
break;
14387+
// TODO: Support other binary operations.
14388+
case ISD::FADD:
14389+
case ISD::FSUB:
14390+
case ISD::FMUL:
14391+
case ISD::ADD:
14392+
case ISD::UMIN:
14393+
case ISD::UMAX:
14394+
case ISD::SMIN:
14395+
case ISD::SMAX:
14396+
case ISD::FMAXNUM:
14397+
case ISD::FMINNUM:
14398+
case ISD::FMAXNUM_IEEE:
14399+
case ISD::FMINNUM_IEEE:
14400+
case ISD::FMAXIMUM:
14401+
case ISD::FMINIMUM: {
14402+
SDValue Elt0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14403+
Vec.getOperand(0), Idx);
14404+
SDValue Elt1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14405+
Vec.getOperand(1), Idx);
14406+
14407+
DCI.AddToWorklist(Elt0.getNode());
14408+
DCI.AddToWorklist(Elt1.getNode());
14409+
return DAG.getNode(Opc, SL, ResVT, Elt0, Elt1, Vec->getFlags());
14410+
}
14411+
}
14412+
}
14413+
14414+
// EXTRACT_VECTOR_ELT (<n x e>, var-idx) => n x select (e, const-idx)
14415+
if (shouldExpandVectorDynExt(N)) {
14416+
SDLoc SL(N);
14417+
SDValue Idx = N->getOperand(1);
14418+
SDValue V;
14419+
for (unsigned I = 0, E = VecVT.getVectorNumElements(); I < E; ++I) {
14420+
SDValue IC = DAG.getVectorIdxConstant(I, SL);
14421+
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec, IC);
14422+
if (I == 0)
14423+
V = Elt;
14424+
else
14425+
V = DAG.getSelectCC(SL, Idx, IC, Elt, V, ISD::SETEQ);
1446814426
}
14427+
return V;
14428+
}
1446914429

14470-
if (!DCI.isBeforeLegalize())
14471-
return SDValue();
14472-
14473-
// Try to turn sub-dword accesses of vectors into accesses of the same
14474-
// 32-bit elements. This exposes more load reduction opportunities by
14475-
// replacing multiple small extract_vector_elements with a single 32-bit
14476-
// extract.
14477-
auto *Idx = dyn_cast<ConstantSDNode>(N->getOperand(1));
14478-
if (isa<MemSDNode>(Vec) && VecEltSize <= 16 && VecEltVT.isByteSized() &&
14479-
VecSize > 32 && VecSize % 32 == 0 && Idx) {
14480-
EVT NewVT = getEquivalentMemType(*DAG.getContext(), VecVT);
14481-
14482-
unsigned BitIndex = Idx->getZExtValue() * VecEltSize;
14483-
unsigned EltIdx = BitIndex / 32;
14484-
unsigned LeftoverBitIdx = BitIndex % 32;
14485-
SDLoc SL(N);
14430+
if (!DCI.isBeforeLegalize())
14431+
return SDValue();
1448614432

14487-
SDValue Cast = DAG.getNode(ISD::BITCAST, SL, NewVT, Vec);
14488-
DCI.AddToWorklist(Cast.getNode());
14433+
// Try to turn sub-dword accesses of vectors into accesses of the same
14434+
// 32-bit elements. This exposes more load reduction opportunities by
14435+
// replacing multiple small extract_vector_elements with a single 32-bit
14436+
// extract.
14437+
auto *Idx = dyn_cast<ConstantSDNode>(N->getOperand(1));
14438+
if (isa<MemSDNode>(Vec) && VecEltSize <= 16 && VecEltVT.isByteSized() &&
14439+
VecSize > 32 && VecSize % 32 == 0 && Idx) {
14440+
EVT NewVT = getEquivalentMemType(*DAG.getContext(), VecVT);
14441+
14442+
unsigned BitIndex = Idx->getZExtValue() * VecEltSize;
14443+
unsigned EltIdx = BitIndex / 32;
14444+
unsigned LeftoverBitIdx = BitIndex % 32;
14445+
SDLoc SL(N);
1448914446

14490-
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, MVT::i32, Cast,
14491-
DAG.getConstant(EltIdx, SL, MVT::i32));
14492-
DCI.AddToWorklist(Elt.getNode());
14493-
SDValue Srl = DAG.getNode(ISD::SRL, SL, MVT::i32, Elt,
14494-
DAG.getConstant(LeftoverBitIdx, SL, MVT::i32));
14495-
DCI.AddToWorklist(Srl.getNode());
14447+
SDValue Cast = DAG.getNode(ISD::BITCAST, SL, NewVT, Vec);
14448+
DCI.AddToWorklist(Cast.getNode());
1449614449

14497-
EVT VecEltAsIntVT = VecEltVT.changeTypeToInteger();
14498-
SDValue Trunc = DAG.getNode(ISD::TRUNCATE, SL, VecEltAsIntVT, Srl);
14499-
DCI.AddToWorklist(Trunc.getNode());
14450+
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, MVT::i32, Cast,
14451+
DAG.getConstant(EltIdx, SL, MVT::i32));
14452+
DCI.AddToWorklist(Elt.getNode());
14453+
SDValue Srl = DAG.getNode(ISD::SRL, SL, MVT::i32, Elt,
14454+
DAG.getConstant(LeftoverBitIdx, SL, MVT::i32));
14455+
DCI.AddToWorklist(Srl.getNode());
1450014456

14501-
if (VecEltVT == ResVT) {
14502-
return DAG.getNode(ISD::BITCAST, SL, VecEltVT, Trunc);
14503-
}
14457+
EVT VecEltAsIntVT = VecEltVT.changeTypeToInteger();
14458+
SDValue Trunc = DAG.getNode(ISD::TRUNCATE, SL, VecEltAsIntVT, Srl);
14459+
DCI.AddToWorklist(Trunc.getNode());
1450414460

14505-
assert(ResVT.isScalarInteger());
14506-
return DAG.getAnyExtOrTrunc(Trunc, SL, ResVT);
14461+
if (VecEltVT == ResVT) {
14462+
return DAG.getNode(ISD::BITCAST, SL, VecEltVT, Trunc);
1450714463
}
1450814464

14509-
return SDValue();
14465+
assert(ResVT.isScalarInteger());
14466+
return DAG.getAnyExtOrTrunc(Trunc, SL, ResVT);
1451014467
}
1451114468

14469+
return SDValue();
14470+
}
14471+
1451214472
SDValue
1451314473
SITargetLowering::performInsertVectorEltCombine(SDNode *N,
1451414474
DAGCombinerInfo &DCI) const {

0 commit comments

Comments
 (0)