Skip to content

Commit fb131f8

Browse files
Rohit AggarwalRohit Aggarwal
authored andcommitted
Remove updateBaseIndex function and update the Checks for testcase
1 parent 4bb9f5b commit fb131f8

File tree

2 files changed

+0
-153
lines changed

2 files changed

+0
-153
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -56508,120 +56508,6 @@ static SDValue rebuildGatherScatter(MaskedGatherScatterSDNode *GorS,
5650856508
Scatter->isTruncatingStore());
5650956509
}
5651056510

56511-
// Target override this function to decide whether it want to update the base
56512-
// and index value of a non-uniform gep
56513-
static bool updateBaseAndIndex(SDValue &Base, SDValue &Index, SDValue &Scale,
56514-
const SDLoc &DL, const SDValue &Gep,
56515-
SelectionDAG &DAG) {
56516-
SDValue Nbase;
56517-
SDValue Nindex;
56518-
SDValue NScale;
56519-
bool Changed = false;
56520-
// This function check the opcode of Index and update the index
56521-
auto checkAndUpdateIndex = [&](SDValue &Idx) {
56522-
if (Idx.getOpcode() == ISD::SHL) { // shl zext, BV
56523-
SDValue Op10 = Idx.getOperand(0); // Zext or Sext value
56524-
SDValue Op11 = Idx.getOperand(1); // Build vector of constant
56525-
std::optional<uint64_t> ShAmt = DAG.getValidMinimumShiftAmount(Idx);
56526-
56527-
unsigned IndexWidth = Op10.getScalarValueSizeInBits();
56528-
if ((Op10.getOpcode() == ISD::SIGN_EXTEND ||
56529-
Op10.getOpcode() == ISD::ZERO_EXTEND) &&
56530-
IndexWidth > 32 &&
56531-
Op10.getOperand(0).getScalarValueSizeInBits() <= 32 &&
56532-
DAG.ComputeNumSignBits(Op10) > (IndexWidth - 32) && ShAmt) {
56533-
56534-
KnownBits ExtKnown = DAG.computeKnownBits(Op10);
56535-
bool ExtIsNonNegative = ExtKnown.isNonNegative();
56536-
KnownBits ExtOpKnown = DAG.computeKnownBits(Op10.getOperand(0));
56537-
bool ExtOpIsNonNegative = ExtOpKnown.isNonNegative();
56538-
if (!ExtIsNonNegative || !ExtOpIsNonNegative)
56539-
return false;
56540-
56541-
SDValue NewOp10 =
56542-
Op10.getOperand(0); // Get the Operand zero from the ext
56543-
EVT VT = NewOp10.getValueType(); // Use the operand's type to determine
56544-
// the type of index
56545-
56546-
// auto *ConstEltNo = dyn_cast<ConstantSDNode>(Op11.getOperand(0));
56547-
// if (!ConstEltNo)
56548-
// return false;
56549-
uint64_t ScaleAmt = cast<ConstantSDNode>(Scale)->getZExtValue();
56550-
uint64_t NewScaleAmt = ScaleAmt * (1ULL << *ShAmt);
56551-
LLVM_DEBUG(dbgs() << NewScaleAmt << " NewScaleAmt"
56552-
<< "\n");
56553-
if (isPowerOf2_64(NewScaleAmt) && NewScaleAmt <= 8) {
56554-
// Nindex = NewOp10.getOperand(0);
56555-
Nindex = Op10;
56556-
NScale = DAG.getTargetConstant(NewScaleAmt, DL, Scale.getValueType());
56557-
return true;
56558-
}
56559-
// SmallVector<SDValue, 8> Ops(VT.getVectorNumElements(),
56560-
// DAG.getConstant(ConstEltNo->getZExtValue(),
56561-
// DL, VT.getScalarType()));
56562-
// Nindex = DAG.getNode(ISD::SHL, DL, VT, NewOp10,
56563-
// DAG.getBuildVector(VT, DL, Ops));
56564-
}
56565-
}
56566-
return false;
56567-
};
56568-
56569-
// For the gep instruction, we are trying to properly assign the base and
56570-
// index value We are go through the lower code and iterate backward.
56571-
if (isNullConstant(Base) && Gep.getOpcode() == ISD::ADD) {
56572-
SDValue Op0 = Gep.getOperand(0); // base or add
56573-
SDValue Op1 = Gep.getOperand(1); // build vector or SHL
56574-
Nbase = Op0;
56575-
SDValue Idx = Op1;
56576-
auto Flags = Gep->getFlags();
56577-
56578-
if (Op0->getOpcode() == ISD::ADD) { // add t15(base), t18(Idx)
56579-
SDValue Op00 = Op0.getOperand(0); // Base
56580-
Nbase = Op00;
56581-
Idx = Op0.getOperand(1);
56582-
} else if (!(Op0->getOpcode() == ISD::BUILD_VECTOR &&
56583-
Op0.getOperand(0).getOpcode() == ISD::CopyFromReg)) {
56584-
return false;
56585-
}
56586-
if (!checkAndUpdateIndex(Idx)) {
56587-
return false;
56588-
}
56589-
Base = Nbase.getOperand(0);
56590-
56591-
if (Op0 != Nbase) {
56592-
auto *ConstEltNo = dyn_cast<ConstantSDNode>(Op1.getOperand(0));
56593-
if (!ConstEltNo)
56594-
return false;
56595-
56596-
// SmallVector<SDValue, 8> Ops(
56597-
// Nindex.getValueType().getVectorNumElements(),
56598-
// DAG.getConstant(ConstEltNo->getZExtValue(), DL,
56599-
// Nindex.getValueType().getScalarType()));
56600-
Base = DAG.getNode(ISD::ADD, DL, Nbase.getOperand(0).getValueType(),
56601-
Nbase.getOperand(0), Op1.getOperand(0), Flags);
56602-
}
56603-
Index = Nindex;
56604-
Scale = NScale;
56605-
Changed = true;
56606-
} else if (Base.getOpcode() == ISD::CopyFromReg ||
56607-
(Base.getOpcode() == ISD::ADD &&
56608-
Base.getOperand(0).getOpcode() == ISD::CopyFromReg &&
56609-
isConstOrConstSplat(Base.getOperand(1)))) {
56610-
if (checkAndUpdateIndex(Index)) {
56611-
Index = Nindex;
56612-
Changed = true;
56613-
}
56614-
}
56615-
if (Changed) {
56616-
LLVM_DEBUG(dbgs() << "Successful in updating the non uniform gep "
56617-
"information\n";
56618-
dbgs() << "updated base "; Base.dump();
56619-
dbgs() << "updated Index "; Index.dump(););
56620-
return true;
56621-
}
56622-
return false;
56623-
}
56624-
5662556511
static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5662656512
TargetLowering::DAGCombinerInfo &DCI) {
5662756513
SDLoc DL(N);
@@ -56634,10 +56520,6 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5663456520
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
5663556521

5663656522
if (DCI.isBeforeLegalize()) {
56637-
// if (updateBaseAndIndex(Base, Index, Scale, DL, Index, DAG))
56638-
// return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
56639-
//
56640-
5664156523
// Attempt to move shifted index into the address scale, allows further
5664256524
// index truncation below.
5664356525
// TODO

llvm/test/CodeGen/X86/masked_gather_scatter.ll

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -604,41 +604,6 @@ define <16 x float> @test13(ptr %base, <16 x i32> %ind) {
604604

605605
; The base pointer is not splat, can't find unform base
606606
define <16 x float> @test14(ptr %base, i32 %ind, <16 x ptr> %vec) {
607-
; KNL_64-LABEL: test14:
608-
; KNL_64: # %bb.0:
609-
; KNL_64-NEXT: vmovq %xmm0, %rax
610-
; KNL_64-NEXT: vpbroadcastd %esi, %zmm1
611-
; KNL_64-NEXT: kxnorw %k0, %k0, %k1
612-
; KNL_64-NEXT: vpxor %xmm0, %xmm0, %xmm0
613-
; KNL_64-NEXT: vgatherdps (%rax,%zmm1,4), %zmm0 {%k1}
614-
; KNL_64-NEXT: retq
615-
;
616-
; KNL_32-LABEL: test14:
617-
; KNL_32: # %bb.0:
618-
; KNL_32-NEXT: vmovd %xmm0, %eax
619-
; KNL_32-NEXT: vbroadcastss {{[0-9]+}}(%esp), %zmm1
620-
; KNL_32-NEXT: kxnorw %k0, %k0, %k1
621-
; KNL_32-NEXT: vpxor %xmm0, %xmm0, %xmm0
622-
; KNL_32-NEXT: vgatherdps (%eax,%zmm1,4), %zmm0 {%k1}
623-
; KNL_32-NEXT: retl
624-
;
625-
; SKX-LABEL: test14:
626-
; SKX: # %bb.0:
627-
; SKX-NEXT: vmovq %xmm0, %rax
628-
; SKX-NEXT: vpbroadcastd %esi, %zmm1
629-
; SKX-NEXT: kxnorw %k0, %k0, %k1
630-
; SKX-NEXT: vpxor %xmm0, %xmm0, %xmm0
631-
; SKX-NEXT: vgatherdps (%rax,%zmm1,4), %zmm0 {%k1}
632-
; SKX-NEXT: retq
633-
;
634-
; SKX_32-LABEL: test14:
635-
; SKX_32: # %bb.0:
636-
; SKX_32-NEXT: vmovd %xmm0, %eax
637-
; SKX_32-NEXT: vbroadcastss {{[0-9]+}}(%esp), %zmm1
638-
; SKX_32-NEXT: kxnorw %k0, %k0, %k1
639-
; SKX_32-NEXT: vpxor %xmm0, %xmm0, %xmm0
640-
; SKX_32-NEXT: vgatherdps (%eax,%zmm1,4), %zmm0 {%k1}
641-
; SKX_32-NEXT: retl
642607
; X64-LABEL: test14:
643608
; X64: # %bb.0:
644609
; X64-NEXT: vmovq %xmm0, %rax

0 commit comments

Comments
 (0)