Skip to content

Commit f0a175a

Browse files
Rohit AggarwalRohit Aggarwal
Rohit Aggarwal
authored and
Rohit Aggarwal
committed
Add test case and merge usecases fo SHL
1 parent b9e571a commit f0a175a

File tree

2 files changed

+454
-8
lines changed

2 files changed

+454
-8
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56523,6 +56523,14 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5652356523
// Attempt to move shifted index into the address scale, allows further
5652456524
// index truncation below.
5652556525
if (Index.getOpcode() == ISD::SHL && isa<ConstantSDNode>(Scale)) {
56526+
unsigned BitWidth = Index.getScalarValueSizeInBits();
56527+
unsigned MaskBits = BitWidth - Log2_32(Scale->getAsZExtVal());
56528+
APInt DemandedBits = APInt::getLowBitsSet(BitWidth, MaskBits);
56529+
if (TLI.SimplifyDemandedBits(Index, DemandedBits, DCI)) {
56530+
if (N->getOpcode() != ISD::DELETED_NODE)
56531+
DCI.AddToWorklist(N);
56532+
return SDValue(N, 0);
56533+
}
5652656534
uint64_t ScaleAmt = Scale->getAsZExtVal();
5652756535
if (auto MinShAmt = DAG.getValidMinimumShiftAmount(Index)) {
5652856536
if (*MinShAmt >= 1 && (*MinShAmt + Log2_64(ScaleAmt)) < 4 &&
@@ -56588,14 +56596,14 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5658856596

5658956597
EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5659056598

56591-
if (Index.getOpcode() == ISD::SHL) {
56592-
unsigned BitWidth = Index.getScalarValueSizeInBits();
56593-
unsigned MaskBits = BitWidth - Log2_32(Scale->getAsZExtVal());
56594-
APInt DemandedBits = APInt::getLowBitsSet(BitWidth, MaskBits);
56595-
if (TLI.SimplifyDemandedBits(Index, DemandedBits, DCI)) {
56596-
return SDValue(N, 0);
56597-
}
56598-
}
56599+
// if (Index.getOpcode() == ISD::SHL) {
56600+
// unsigned BitWidth = Index.getScalarValueSizeInBits();
56601+
// unsigned MaskBits = BitWidth - Log2_32(Scale->getAsZExtVal());
56602+
// APInt DemandedBits = APInt::getLowBitsSet(BitWidth, MaskBits);
56603+
// if (TLI.SimplifyDemandedBits(Index, DemandedBits, DCI)) {
56604+
// return SDValue(N, 0);
56605+
// }
56606+
// }
5659956607
// Try to move splat adders from the index operand to the base
5660056608
// pointer operand. Taking care to multiply by the scale. We can only do
5660156609
// this when index element type is the same as the pointer type.

0 commit comments

Comments
 (0)