Skip to content

Commit f077422

Browse files
committed
Fix formatting
1 parent 69f1504 commit f077422

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
@@ -4063,7 +4063,6 @@ SDValue AMDGPUTargetLowering::splitBinaryBitConstantOpImpl(
40634063
// scalarises the AND for this optimisation case.
40644064
static SDValue getShiftForReduction(unsigned ShiftOpc, SDValue LHS, SDValue RHS,
40654065
SelectionDAG &DAG) {
4066-
40674066
assert(
40684067
(ShiftOpc == ISD::SRA || ShiftOpc == ISD::SRL || ShiftOpc == ISD::SHL) &&
40694068
"Expected shift Opcode.");

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 105 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -13342,7 +13342,6 @@ SDValue SITargetLowering::performXorCombine(SDNode *N,
1334213342
// v2i32 (xor (vselect cc, x, y), K) ->
1334313343
// (v2i32 svelect cc, (xor x, K), (xor y, K)) This enables the xor to be
1334413344
// replaced with source modifiers when the select is lowered to CNDMASK.
13345-
// TODO REMOVE: prevents regressions in fneg-modifier-casting.ll
1334613345
unsigned Opc = LHS.getOpcode();
1334713346
if(((Opc == ISD::VSELECT && VT==MVT::v2i32) || (Opc == ISD::SELECT && VT==MVT::i64)) && CRHS && CRHS->getAPIntValue().isSignMask()) {
1334813347
SDValue CC = LHS->getOperand(0);
@@ -14320,165 +14319,126 @@ bool SITargetLowering::shouldExpandVectorDynExt(SDNode *N) const {
1432014319
EltSize, NumElem, Idx->isDivergent(), getSubtarget());
1432114320
}
1432214321

14323-
// SDValue
14324-
// SITargetLowering::performBuildVectorCombine(SDNode *N,
14325-
// DAGCombinerInfo &DCI) const {
14326-
// // if (N->use_empty())
14327-
// // return SDValue();
14328-
14329-
// // if(!N->getValueType(0).isFloatingPoint())
14330-
// // return SDValue();
14331-
14332-
// // SelectionDAG &DAG = DCI.DAG;
14333-
14334-
// // // Iterate the operands. Check if source modifier. If so, propogate the
14335-
// // source
14336-
// // // modifier to the user and the srcmod from the BUILD_VECTOR element.
14337-
// // for (unsigned I = 0; I < N->getNumOperands(); I++) {
14338-
// // SDValue E = N->getOperand(I);
14339-
// // if (E->getOpcode() != ISD::FNEG && E->getOpcode() != ISD::ABS)
14340-
// // continue;
14341-
14342-
// // // Users through which we can propogate will include users of
14343-
// // // extract_element on this vector, so need to peek-through.
14344-
// // }
14345-
14346-
// // SmallVector<SDNode*, 4> UsersToModify;
14347-
14348-
// // // If the use of the BUILD_VECTOR supports source mods it can be
14349-
// // propogated. for (SDNode *U : N->users()) {
14350-
// // if(!U->getOpcode() == ISD::EXTRACT_VECTOR_ELT)
14351-
// // if (!allUsesHaveSourceMods(U))
14352-
// // continue;
14353-
// // UsersToModify.push_back(U);
14354-
// // }
14355-
14356-
// // for(auto Node: UsersToModify) {
14357-
14358-
// // }
14359-
14360-
// return SDValue();
14361-
// }
14362-
14363-
SDValue SITargetLowering::performExtractVectorEltCombine(
14364-
SDNode * N, DAGCombinerInfo & DCI) const {
14365-
SDValue Vec = N->getOperand(0);
14366-
SelectionDAG &DAG = DCI.DAG;
14367-
14368-
EVT VecVT = Vec.getValueType();
14369-
EVT VecEltVT = VecVT.getVectorElementType();
14370-
EVT ResVT = N->getValueType(0);
14322+
SDValue
14323+
SITargetLowering::performExtractVectorEltCombine(SDNode *N,
14324+
DAGCombinerInfo &DCI) const {
14325+
SDValue Vec = N->getOperand(0);
14326+
SelectionDAG &DAG = DCI.DAG;
1437114327

14372-
unsigned VecSize = VecVT.getSizeInBits();
14373-
unsigned VecEltSize = VecEltVT.getSizeInBits();
14328+
EVT VecVT = Vec.getValueType();
14329+
EVT VecEltVT = VecVT.getVectorElementType();
14330+
EVT ResVT = N->getValueType(0);
1437414331

14375-
if ((Vec.getOpcode() == ISD::FNEG || Vec.getOpcode() == ISD::FABS) &&
14376-
allUsesHaveSourceMods(N)) {
14377-
SDLoc SL(N);
14378-
SDValue Idx = N->getOperand(1);
14379-
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14380-
Vec.getOperand(0), Idx);
14381-
return DAG.getNode(Vec.getOpcode(), SL, ResVT, Elt);
14382-
}
14383-
14384-
// ScalarRes = EXTRACT_VECTOR_ELT ((vector-BINOP Vec1, Vec2), Idx)
14385-
// =>
14386-
// Vec1Elt = EXTRACT_VECTOR_ELT(Vec1, Idx)
14387-
// Vec2Elt = EXTRACT_VECTOR_ELT(Vec2, Idx)
14388-
// ScalarRes = scalar-BINOP Vec1Elt, Vec2Elt
14389-
if (Vec.hasOneUse() && DCI.isBeforeLegalize() && VecEltVT == ResVT) {
14390-
SDLoc SL(N);
14391-
SDValue Idx = N->getOperand(1);
14392-
unsigned Opc = Vec.getOpcode();
14332+
unsigned VecSize = VecVT.getSizeInBits();
14333+
unsigned VecEltSize = VecEltVT.getSizeInBits();
1439314334

14394-
switch (Opc) {
14395-
default:
14396-
break;
14397-
// TODO: Support other binary operations.
14398-
case ISD::FADD:
14399-
case ISD::FSUB:
14400-
case ISD::FMUL:
14401-
case ISD::ADD:
14402-
case ISD::UMIN:
14403-
case ISD::UMAX:
14404-
case ISD::SMIN:
14405-
case ISD::SMAX:
14406-
case ISD::FMAXNUM:
14407-
case ISD::FMINNUM:
14408-
case ISD::FMAXNUM_IEEE:
14409-
case ISD::FMINNUM_IEEE:
14410-
case ISD::FMAXIMUM:
14411-
case ISD::FMINIMUM: {
14412-
SDValue Elt0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14413-
Vec.getOperand(0), Idx);
14414-
SDValue Elt1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14415-
Vec.getOperand(1), Idx);
14416-
14417-
DCI.AddToWorklist(Elt0.getNode());
14418-
DCI.AddToWorklist(Elt1.getNode());
14419-
return DAG.getNode(Opc, SL, ResVT, Elt0, Elt1, Vec->getFlags());
14420-
}
14421-
}
14422-
}
14335+
if ((Vec.getOpcode() == ISD::FNEG || Vec.getOpcode() == ISD::FABS) &&
14336+
allUsesHaveSourceMods(N)) {
14337+
SDLoc SL(N);
14338+
SDValue Idx = N->getOperand(1);
14339+
SDValue Elt =
14340+
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec.getOperand(0), Idx);
14341+
return DAG.getNode(Vec.getOpcode(), SL, ResVT, Elt);
14342+
}
14343+
14344+
// ScalarRes = EXTRACT_VECTOR_ELT ((vector-BINOP Vec1, Vec2), Idx)
14345+
// =>
14346+
// Vec1Elt = EXTRACT_VECTOR_ELT(Vec1, Idx)
14347+
// Vec2Elt = EXTRACT_VECTOR_ELT(Vec2, Idx)
14348+
// ScalarRes = scalar-BINOP Vec1Elt, Vec2Elt
14349+
if (Vec.hasOneUse() && DCI.isBeforeLegalize() && VecEltVT == ResVT) {
14350+
SDLoc SL(N);
14351+
SDValue Idx = N->getOperand(1);
14352+
unsigned Opc = Vec.getOpcode();
1442314353

14424-
// EXTRACT_VECTOR_ELT (<n x e>, var-idx) => n x select (e, const-idx)
14425-
if (shouldExpandVectorDynExt(N)) {
14426-
SDLoc SL(N);
14427-
SDValue Idx = N->getOperand(1);
14428-
SDValue V;
14429-
for (unsigned I = 0, E = VecVT.getVectorNumElements(); I < E; ++I) {
14430-
SDValue IC = DAG.getVectorIdxConstant(I, SL);
14431-
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec, IC);
14432-
if (I == 0)
14433-
V = Elt;
14434-
else
14435-
V = DAG.getSelectCC(SL, Idx, IC, Elt, V, ISD::SETEQ);
14436-
}
14437-
return V;
14354+
switch (Opc) {
14355+
default:
14356+
break;
14357+
// TODO: Support other binary operations.
14358+
case ISD::FADD:
14359+
case ISD::FSUB:
14360+
case ISD::FMUL:
14361+
case ISD::ADD:
14362+
case ISD::UMIN:
14363+
case ISD::UMAX:
14364+
case ISD::SMIN:
14365+
case ISD::SMAX:
14366+
case ISD::FMAXNUM:
14367+
case ISD::FMINNUM:
14368+
case ISD::FMAXNUM_IEEE:
14369+
case ISD::FMINNUM_IEEE:
14370+
case ISD::FMAXIMUM:
14371+
case ISD::FMINIMUM: {
14372+
SDValue Elt0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14373+
Vec.getOperand(0), Idx);
14374+
SDValue Elt1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT,
14375+
Vec.getOperand(1), Idx);
14376+
14377+
DCI.AddToWorklist(Elt0.getNode());
14378+
DCI.AddToWorklist(Elt1.getNode());
14379+
return DAG.getNode(Opc, SL, ResVT, Elt0, Elt1, Vec->getFlags());
14380+
}
14381+
}
14382+
}
14383+
14384+
// EXTRACT_VECTOR_ELT (<n x e>, var-idx) => n x select (e, const-idx)
14385+
if (shouldExpandVectorDynExt(N)) {
14386+
SDLoc SL(N);
14387+
SDValue Idx = N->getOperand(1);
14388+
SDValue V;
14389+
for (unsigned I = 0, E = VecVT.getVectorNumElements(); I < E; ++I) {
14390+
SDValue IC = DAG.getVectorIdxConstant(I, SL);
14391+
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, ResVT, Vec, IC);
14392+
if (I == 0)
14393+
V = Elt;
14394+
else
14395+
V = DAG.getSelectCC(SL, Idx, IC, Elt, V, ISD::SETEQ);
1443814396
}
14397+
return V;
14398+
}
1443914399

14440-
if (!DCI.isBeforeLegalize())
14441-
return SDValue();
14442-
14443-
// Try to turn sub-dword accesses of vectors into accesses of the same
14444-
// 32-bit elements. This exposes more load reduction opportunities by
14445-
// replacing multiple small extract_vector_elements with a single 32-bit
14446-
// extract.
14447-
auto *Idx = dyn_cast<ConstantSDNode>(N->getOperand(1));
14448-
if (isa<MemSDNode>(Vec) && VecEltSize <= 16 && VecEltVT.isByteSized() &&
14449-
VecSize > 32 && VecSize % 32 == 0 && Idx) {
14450-
EVT NewVT = getEquivalentMemType(*DAG.getContext(), VecVT);
14451-
14452-
unsigned BitIndex = Idx->getZExtValue() * VecEltSize;
14453-
unsigned EltIdx = BitIndex / 32;
14454-
unsigned LeftoverBitIdx = BitIndex % 32;
14455-
SDLoc SL(N);
14400+
if (!DCI.isBeforeLegalize())
14401+
return SDValue();
1445614402

14457-
SDValue Cast = DAG.getNode(ISD::BITCAST, SL, NewVT, Vec);
14458-
DCI.AddToWorklist(Cast.getNode());
14403+
// Try to turn sub-dword accesses of vectors into accesses of the same
14404+
// 32-bit elements. This exposes more load reduction opportunities by
14405+
// replacing multiple small extract_vector_elements with a single 32-bit
14406+
// extract.
14407+
auto *Idx = dyn_cast<ConstantSDNode>(N->getOperand(1));
14408+
if (isa<MemSDNode>(Vec) && VecEltSize <= 16 && VecEltVT.isByteSized() &&
14409+
VecSize > 32 && VecSize % 32 == 0 && Idx) {
14410+
EVT NewVT = getEquivalentMemType(*DAG.getContext(), VecVT);
14411+
14412+
unsigned BitIndex = Idx->getZExtValue() * VecEltSize;
14413+
unsigned EltIdx = BitIndex / 32;
14414+
unsigned LeftoverBitIdx = BitIndex % 32;
14415+
SDLoc SL(N);
1445914416

14460-
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, MVT::i32, Cast,
14461-
DAG.getConstant(EltIdx, SL, MVT::i32));
14462-
DCI.AddToWorklist(Elt.getNode());
14463-
SDValue Srl = DAG.getNode(ISD::SRL, SL, MVT::i32, Elt,
14464-
DAG.getConstant(LeftoverBitIdx, SL, MVT::i32));
14465-
DCI.AddToWorklist(Srl.getNode());
14417+
SDValue Cast = DAG.getNode(ISD::BITCAST, SL, NewVT, Vec);
14418+
DCI.AddToWorklist(Cast.getNode());
1446614419

14467-
EVT VecEltAsIntVT = VecEltVT.changeTypeToInteger();
14468-
SDValue Trunc = DAG.getNode(ISD::TRUNCATE, SL, VecEltAsIntVT, Srl);
14469-
DCI.AddToWorklist(Trunc.getNode());
14420+
SDValue Elt = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, MVT::i32, Cast,
14421+
DAG.getConstant(EltIdx, SL, MVT::i32));
14422+
DCI.AddToWorklist(Elt.getNode());
14423+
SDValue Srl = DAG.getNode(ISD::SRL, SL, MVT::i32, Elt,
14424+
DAG.getConstant(LeftoverBitIdx, SL, MVT::i32));
14425+
DCI.AddToWorklist(Srl.getNode());
1447014426

14471-
if (VecEltVT == ResVT) {
14472-
return DAG.getNode(ISD::BITCAST, SL, VecEltVT, Trunc);
14473-
}
14427+
EVT VecEltAsIntVT = VecEltVT.changeTypeToInteger();
14428+
SDValue Trunc = DAG.getNode(ISD::TRUNCATE, SL, VecEltAsIntVT, Srl);
14429+
DCI.AddToWorklist(Trunc.getNode());
1447414430

14475-
assert(ResVT.isScalarInteger());
14476-
return DAG.getAnyExtOrTrunc(Trunc, SL, ResVT);
14431+
if (VecEltVT == ResVT) {
14432+
return DAG.getNode(ISD::BITCAST, SL, VecEltVT, Trunc);
1447714433
}
1447814434

14479-
return SDValue();
14435+
assert(ResVT.isScalarInteger());
14436+
return DAG.getAnyExtOrTrunc(Trunc, SL, ResVT);
1448014437
}
1448114438

14439+
return SDValue();
14440+
}
14441+
1448214442
SDValue
1448314443
SITargetLowering::performInsertVectorEltCombine(SDNode *N,
1448414444
DAGCombinerInfo &DCI) const {

0 commit comments

Comments
 (0)