Skip to content

Commit 81052e9

Browse files
committed
Code review comments
- Early exit if optimizing for size - Fix loop condition to check if CurrInstr is not null - use .empty() instead of begin() != end() - Rename pattern enum
1 parent d92972e commit 81052e9

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7329,9 +7329,9 @@ bool AArch64InstrInfo::isThroughputPattern(unsigned Pattern) const {
73297329
case AArch64MachineCombinerPattern::MULSUBv2i32_indexed_OP2:
73307330
case AArch64MachineCombinerPattern::MULSUBv4i32_indexed_OP1:
73317331
case AArch64MachineCombinerPattern::MULSUBv4i32_indexed_OP2:
7332-
case AArch64MachineCombinerPattern::GATHER_i32:
7333-
case AArch64MachineCombinerPattern::GATHER_i16:
7334-
case AArch64MachineCombinerPattern::GATHER_i8:
7332+
case AArch64MachineCombinerPattern::GATHER_LANE_i32:
7333+
case AArch64MachineCombinerPattern::GATHER_LANE_i16:
7334+
case AArch64MachineCombinerPattern::GATHER_LANE_i8:
73357335
return true;
73367336
} // end switch (Pattern)
73377337
return false;
@@ -7375,6 +7375,10 @@ static bool getMiscPatterns(MachineInstr &Root,
73757375
static bool getGatherPattern(MachineInstr &Root,
73767376
SmallVectorImpl<unsigned> &Patterns,
73777377
unsigned LoadLaneOpCode, unsigned NumLanes) {
7378+
// Early exit if optimizing for size.
7379+
if (Root.getMF()->getFunction().hasMinSize())
7380+
return false;
7381+
73787382
const MachineRegisterInfo &MRI = Root.getMF()->getRegInfo();
73797383
const TargetRegisterInfo *TRI =
73807384
Root.getMF()->getSubtarget().getRegisterInfo();
@@ -7391,7 +7395,7 @@ static bool getGatherPattern(MachineInstr &Root,
73917395
auto *CurrInstr = MRI.getUniqueVRegDef(Root.getOperand(1).getReg());
73927396
auto Range = llvm::seq<unsigned>(1, NumLanes - 1);
73937397
SmallSet<unsigned, 4> RemainingLanes(Range.begin(), Range.end());
7394-
while (RemainingLanes.begin() != RemainingLanes.end() &&
7398+
while (!RemainingLanes.empty() && CurrInstr &&
73957399
CurrInstr->getOpcode() == LoadLaneOpCode &&
73967400
MRI.hasOneNonDBGUse(CurrInstr->getOperand(0).getReg()) &&
73977401
CurrInstr->getNumOperands() == 4) {
@@ -7418,13 +7422,13 @@ static bool getGatherPattern(MachineInstr &Root,
74187422

74197423
switch (NumLanes) {
74207424
case 4:
7421-
Patterns.push_back(AArch64MachineCombinerPattern::GATHER_i32);
7425+
Patterns.push_back(AArch64MachineCombinerPattern::GATHER_LANE_i32);
74227426
break;
74237427
case 8:
7424-
Patterns.push_back(AArch64MachineCombinerPattern::GATHER_i16);
7428+
Patterns.push_back(AArch64MachineCombinerPattern::GATHER_LANE_i16);
74257429
break;
74267430
case 16:
7427-
Patterns.push_back(AArch64MachineCombinerPattern::GATHER_i8);
7431+
Patterns.push_back(AArch64MachineCombinerPattern::GATHER_LANE_i8);
74287432
break;
74297433
default:
74307434
llvm_unreachable("Got bad number of lanes for gather pattern.");
@@ -7434,8 +7438,8 @@ static bool getGatherPattern(MachineInstr &Root,
74347438
}
74357439

74367440
/// Search for patterns where we use LD1 instructions to load into
7437-
/// separate lanes of an 128 bit Neon register. We can increase MLP
7438-
/// by loading into 2 Neon registers instead.
7441+
/// separate lanes of an 128 bit Neon register. We can increase Memory Level
7442+
/// Parallelism by loading into 2 Neon registers instead.
74397443
static bool getLoadPatterns(MachineInstr &Root,
74407444
SmallVectorImpl<unsigned> &Patterns) {
74417445

@@ -7604,9 +7608,9 @@ AArch64InstrInfo::getCombinerObjective(unsigned Pattern) const {
76047608
switch (Pattern) {
76057609
case AArch64MachineCombinerPattern::SUBADD_OP1:
76067610
case AArch64MachineCombinerPattern::SUBADD_OP2:
7607-
case AArch64MachineCombinerPattern::GATHER_i32:
7608-
case AArch64MachineCombinerPattern::GATHER_i16:
7609-
case AArch64MachineCombinerPattern::GATHER_i8:
7611+
case AArch64MachineCombinerPattern::GATHER_LANE_i32:
7612+
case AArch64MachineCombinerPattern::GATHER_LANE_i16:
7613+
case AArch64MachineCombinerPattern::GATHER_LANE_i8:
76107614
return CombinerObjective::MustReduceDepth;
76117615
default:
76127616
return TargetInstrInfo::getCombinerObjective(Pattern);
@@ -8895,17 +8899,17 @@ void AArch64InstrInfo::genAlternativeCodeSequence(
88958899
MUL = genFNegatedMAD(MF, MRI, TII, Root, InsInstrs);
88968900
break;
88978901
}
8898-
case AArch64MachineCombinerPattern::GATHER_i32: {
8902+
case AArch64MachineCombinerPattern::GATHER_LANE_i32: {
88998903
generateGatherPattern(Root, InsInstrs, DelInstrs, InstrIdxForVirtReg,
89008904
Pattern, 4);
89018905
break;
89028906
}
8903-
case AArch64MachineCombinerPattern::GATHER_i16: {
8907+
case AArch64MachineCombinerPattern::GATHER_LANE_i16: {
89048908
generateGatherPattern(Root, InsInstrs, DelInstrs, InstrIdxForVirtReg,
89058909
Pattern, 8);
89068910
break;
89078911
}
8908-
case AArch64MachineCombinerPattern::GATHER_i8: {
8912+
case AArch64MachineCombinerPattern::GATHER_LANE_i8: {
89098913
generateGatherPattern(Root, InsInstrs, DelInstrs, InstrIdxForVirtReg,
89108914
Pattern, 16);
89118915
break;

llvm/lib/Target/AArch64/AArch64InstrInfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ enum AArch64MachineCombinerPattern : unsigned {
173173

174174
FNMADD,
175175

176-
GATHER_i32,
177-
GATHER_i16,
178-
GATHER_i8
176+
GATHER_LANE_i32,
177+
GATHER_LANE_i16,
178+
GATHER_LANE_i8
179179
};
180180
class AArch64InstrInfo final : public AArch64GenInstrInfo {
181181
const AArch64RegisterInfo RI;

0 commit comments

Comments
 (0)