Skip to content

Commit a37bd51

Browse files
Artem Gindinsonigcbot
authored andcommitted
Discontinue pre-LLVM 14 support in VectorCompiler
Clean up corresponding `LLVM_VERSION_MAJOR` macro checks.
1 parent 58f0139 commit a37bd51

25 files changed

+39
-246
lines changed

IGC/VectorCompiler/CMCL/lib/Support/BuiltinTranslator.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,7 @@ Value &createMainInst<BuiltinID::Gather>(const std::vector<Value *> &Operands,
350350
cast<ConstantInt>(Operands[GatherOperand::Alignment])->getZExtValue());
351351
auto *MaskV = IRB.CreateTrunc(Operands[GatherOperand::Mask], MaskVTy);
352352
auto *PassthruV = Operands[GatherOperand::Passthru];
353-
354-
#if LLVM_VERSION_MAJOR > 12
355353
auto *GatherV = IRB.CreateMaskedGather(RetVTy, PtrV, Align, MaskV, PassthruV);
356-
#else
357-
auto *GatherV = IRB.CreateMaskedGather(PtrV, Align, MaskV, PassthruV);
358-
#endif
359354

360355
return *GatherV;
361356
}

IGC/VectorCompiler/include/vc/Support/GenXDiagnostic.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ namespace vc {
3131

3232
// Prints \p V to string \p Str.
3333
template <typename T> void printToString(std::string &Str, T &V) {
34-
#if LLVM_VERSION_MAJOR < 10
35-
llvm::raw_string_ostream StrStream{Str};
36-
StrStream << V;
37-
#else
3834
llvm::raw_string_ostream{Str} << V;
39-
#endif
4035
}
4136

4237
enum class WarningName {

IGC/VectorCompiler/include/vc/Utils/GenX/TypeSize.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,17 @@ class TypeSizeWrapper {
3535
public:
3636
using SzType = uint64_t;
3737

38-
#if LLVM_VERSION_MAJOR >= 10
3938
using DLTypeSize = llvm::TypeSize;
4039
static DLTypeSize InvalidDLSize() {
4140
return DLTypeSize::Fixed(0);
4241
}
4342
static DLTypeSize FixedDLSize(uint64_t SZ) {
4443
return DLTypeSize::Fixed(SZ);
4544
}
46-
#else
47-
using DLTypeSize = uint64_t;
48-
static DLTypeSize InvalidDLSize() {
49-
return 0;
50-
}
51-
static DLTypeSize FixedDLSize(uint64_t SZ) {
52-
return SZ;
53-
}
54-
#endif
5545

5646
TypeSizeWrapper() = default;
5747
TypeSizeWrapper(DLTypeSize TS) : TS(TS){};
58-
#if LLVM_VERSION_MAJOR >= 10
5948
TypeSizeWrapper(uint64_t TSIn) : TS{FixedDLSize(TSIn)} {};
60-
#endif
6149

6250
SzType inBytesCeil() const { return asIntegralCeil<ByteBits>(); }
6351
SzType inWordsCeil() const { return asIntegralCeil<WordBits>(); }
@@ -119,12 +107,8 @@ class TypeSizeWrapper {
119107
}
120108

121109
template <unsigned UnitBitSize, bool Strict> SzType asIntegral() const {
122-
#if LLVM_VERSION_MAJOR >= 10
123110
IGC_ASSERT(!TS.isScalable());
124111
uint64_t BitsAsUI = TS.getFixedSize();
125-
#else
126-
uint64_t BitsAsUI = TS;
127-
#endif
128112
IGC_ASSERT_MESSAGE(BitsAsUI <= std::numeric_limits<SzType>::max(),
129113
"Type is too large to operate on");
130114
IGC_ASSERT_MESSAGE(BitsAsUI >= 0, "Could not determine size of Type");

IGC/VectorCompiler/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ static void optimizeIR(const vc::CompileOptions &Opts,
364364
PMBuilder.LoopVectorize = false;
365365
PMBuilder.DisableUnrollLoops = false;
366366
PMBuilder.MergeFunctions = false;
367-
#if LLVM_VERSION_MAJOR <= 14
367+
#if LLVM_VERSION_MAJOR < 15
368368
PMBuilder.PrepareForThinLTO = false;
369369
PMBuilder.PrepareForLTO = false;
370370
#endif

IGC/VectorCompiler/lib/GenXCodeGen/GenXBFloatLowering.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class GenXBFloatLowering : public FunctionPass,
5555

5656
public:
5757
static char ID;
58-
#if LLVM_VERSION_MAJOR > 10
5958
// fadd, fsub e.t.c
6059
void visitBinaryOperator(BinaryOperator &Inst);
6160
// fneg
@@ -81,7 +80,6 @@ class GenXBFloatLowering : public FunctionPass,
8180
void lowerCastToBFloat(CastInst &Inst);
8281
void lowerCastFromBFloat(CastInst &Inst);
8382

84-
#endif // LLVM_VERSION_MAJOR > 10
8583
};
8684

8785
} // end namespace
@@ -104,7 +102,6 @@ void GenXBFloatLowering::getAnalysisUsage(AnalysisUsage &AU) const {
104102
AU.addRequired<TargetPassConfig>();
105103
}
106104

107-
#if LLVM_VERSION_MAJOR > 10
108105
static Type *getFloatTyFromBfloat(Type *Ty) {
109106
IGC_ASSERT_EXIT(Ty->getScalarType()->isBFloatTy());
110107
auto *FloatTy = Type::getFloatTy(Ty->getContext());
@@ -348,7 +345,6 @@ void GenXBFloatLowering::lowerCastFromBFloat(CastInst &Inst) {
348345
Inst.eraseFromParent();
349346
Modify = true;
350347
}
351-
#endif // LLVM_VERSION_MAJOR > 10
352348

353349
/***********************************************************************
354350
* GenXBFloatLowering::runOnFunction
@@ -358,13 +354,11 @@ bool GenXBFloatLowering::runOnFunction(Function &F) {
358354
return false;
359355
LLVM_DEBUG(dbgs() << "GenXBFloatLowering started\n");
360356

361-
#if LLVM_VERSION_MAJOR > 10
362357
ST = &getAnalysis<TargetPassConfig>()
363358
.getTM<GenXTargetMachine>()
364359
.getGenXSubtarget();
365360

366361
visit(F);
367-
#endif // LLVM_VERSION_MAJOR > 10
368362

369363
LLVM_DEBUG(dbgs() << "GenXBFloatLowering ended\n");
370364
return Modify;

IGC/VectorCompiler/lib/GenXCodeGen/GenXConstants.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,7 @@ bool ConstantLoadHelper::visitBinaryOperator(BinaryOperator &BO) {
297297
auto *STy = Ty->getScalarType();
298298

299299
// BFloat and boolean (except not) operations do not support immediate values.
300-
#if LLVM_VERSION_MAJOR > 10
301300
if (!STy->isIntegerTy(1) && !STy->isBFloatTy())
302-
#else // LLVM_VERSION_MAJOR > 10
303-
if (!STy->isIntegerTy(1))
304-
#endif // LLVM_VERSION_MAJOR > 10
305301
return false;
306302

307303
bool Modified = false;
@@ -327,12 +323,7 @@ bool ConstantLoadHelper::visitBinaryOperator(BinaryOperator &BO) {
327323
bool ConstantLoadHelper::visitSelectInst(SelectInst &SI) {
328324
// select: disallow constant selector and bfloat immediate values.
329325
bool Modified = false;
330-
const bool IsBFloat =
331-
#if LLVM_VERSION_MAJOR > 10
332-
SI.getType()->getScalarType()->isBFloatTy();
333-
#else // LLVM_VERSION_MAJOR > 10
334-
false;
335-
#endif // LLVM_VERSION_MAJOR > 10
326+
const bool IsBFloat = SI.getType()->getScalarType()->isBFloatTy();
336327

337328
for (int I = 0; I < (IsBFloat ? 3 : 1); I++) {
338329
auto *U = &SI.getOperandUse(I);
@@ -557,11 +548,7 @@ bool ConstantLoadHelper::visitCallInst(CallInst &CI) {
557548
break;
558549
}
559550
// Allow non-bfloat constant if the instruction supports immediate values.
560-
#if LLVM_VERSION_MAJOR > 10
561551
if (!AI.isImmediateDisallowed() && !CTy->isBFloatTy())
562-
#else // LLVM_VERSION_MAJOR > 10
563-
if (!AI.isImmediateDisallowed())
564-
#endif // LLVM_VERSION_MAJOR > 10
565552
continue;
566553
// Operand is not allowed to be constant. Insert code to load it.
567554
*U = ConstantLoader(C, ST, DL, nullptr, AddedInst).loadBig(&CI);
@@ -1435,7 +1422,6 @@ Instruction *ConstantLoader::load(Instruction *InsertBefore) {
14351422
auto IntrinsicID = GenXIntrinsic::genx_constanti;
14361423

14371424
if (C->getType()->isFPOrFPVectorTy()) {
1438-
#if LLVM_VERSION_MAJOR > 10
14391425
if (Ty->getScalarType()->isBFloatTy()) {
14401426
Type *NewTy = Builder.getInt16Ty();
14411427
if (auto *VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty))
@@ -1444,7 +1430,6 @@ Instruction *ConstantLoader::load(Instruction *InsertBefore) {
14441430
Args[0] = NewC;
14451431
OverloadedTypes[0] = NewTy;
14461432
} else
1447-
#endif // LLVM_VERSION_MAJOR > 10
14481433
IntrinsicID = GenXIntrinsic::genx_constantf;
14491434
} else if (C->getType()->getScalarType()->isIntegerTy(1)) {
14501435
IntrinsicID = GenXIntrinsic::genx_constantpred;

IGC/VectorCompiler/lib/GenXCodeGen/GenXDebugLegalization.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ bool GenXDebugLegalization::extractAddressClass(Function &F) {
9797

9898
if (newElements.size() < DIExpr->getNumElements()) {
9999
DIExpression* newDIExpr = di.createExpression(newElements);
100-
#if LLVM_VERSION_MAJOR < 13
101-
DI->setArgOperand(2, MetadataAsValue::get(newDIExpr->getContext(), newDIExpr));
102-
#else
103100
DI->setExpression(newDIExpr);
104-
#endif
105101
Modified = true;
106102
}
107103
}
@@ -114,7 +110,6 @@ bool GenXDebugLegalization::extractAddressClass(Function &F) {
114110
// In order to prevent crashes, remove such metadata.
115111
bool GenXDebugLegalization::removeDIArgList(Function &F) {
116112
bool Modified = false;
117-
#if LLVM_VERSION_MAJOR > 12
118113
for (auto &BB : F) {
119114
for (auto &I : BB) {
120115
if (auto *dbgInst = dyn_cast<DbgVariableIntrinsic>(&I)) {
@@ -125,7 +120,6 @@ bool GenXDebugLegalization::removeDIArgList(Function &F) {
125120
}
126121
}
127122
}
128-
#endif
129123
return Modified;
130124
}
131125

IGC/VectorCompiler/lib/GenXCodeGen/GenXLowering.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,13 +2091,11 @@ bool GenXLowering::processInst(Instruction *Inst) {
20912091
return lowerCttz(CI);
20922092
case Intrinsic::ctlz:
20932093
return lowerCtlz(CI);
2094-
#if LLVM_VERSION_MAJOR >= 12
20952094
case Intrinsic::smin:
20962095
case Intrinsic::smax:
20972096
case Intrinsic::umin:
20982097
case Intrinsic::umax:
20992098
return lowerMinMax(CI, IntrinsicID);
2100-
#endif
21012099
case Intrinsic::sqrt:
21022100
return lowerSqrt(CI);
21032101
case Intrinsic::sadd_sat:
@@ -2137,9 +2135,7 @@ bool GenXLowering::processInst(Instruction *Inst) {
21372135
case Intrinsic::fshl:
21382136
case Intrinsic::fshr:
21392137
return lowerFunnelShift(CI, IntrinsicID);
2140-
#if LLVM_VERSION_MAJOR >= 12
21412138
case Intrinsic::abs:
2142-
#endif
21432139
case Intrinsic::fabs:
21442140
return lowerAbs(CI);
21452141
case Intrinsic::ceil:
@@ -2152,7 +2148,6 @@ bool GenXLowering::processInst(Instruction *Inst) {
21522148
return lowerStackSave(CI);
21532149
case Intrinsic::stackrestore:
21542150
return lowerStackRestore(CI);
2155-
#if LLVM_VERSION_MAJOR >= 12
21562151
case Intrinsic::vector_reduce_add:
21572152
return lowerReduction(CI, Instruction::Add);
21582153
case Intrinsic::vector_reduce_mul:
@@ -2165,20 +2160,6 @@ bool GenXLowering::processInst(Instruction *Inst) {
21652160
return lowerReduction(CI, Intrinsic::maxnum);
21662161
case Intrinsic::vector_reduce_fmin:
21672162
return lowerReduction(CI, Intrinsic::minnum);
2168-
#else // LLVM_VERSION_MAJOR >= 12
2169-
case Intrinsic::experimental_vector_reduce_add:
2170-
return lowerReduction(CI, Instruction::Add);
2171-
case Intrinsic::experimental_vector_reduce_mul:
2172-
return lowerReduction(CI, Instruction::Mul);
2173-
case Intrinsic::experimental_vector_reduce_v2_fadd:
2174-
return lowerReduction(CI, Instruction::FAdd);
2175-
case Intrinsic::experimental_vector_reduce_v2_fmul:
2176-
return lowerReduction(CI, Instruction::FMul);
2177-
case Intrinsic::experimental_vector_reduce_fmax:
2178-
return lowerReduction(CI, Intrinsic::maxnum);
2179-
case Intrinsic::experimental_vector_reduce_fmin:
2180-
return lowerReduction(CI, Intrinsic::minnum);
2181-
#endif // LLVM_VERSION_MAJOR >= 12
21822163
case GenXIntrinsic::genx_get_hwid:
21832164
return lowerHardwareThreadID(CI);
21842165
case vc::InternalIntrinsic::logical_thread_id:
@@ -3712,7 +3693,6 @@ bool GenXLowering::lowerUnorderedFCmpInst(FCmpInst *Inst) {
37123693
}
37133694

37143695
static GenXIntrinsic::ID convertMinMaxIntrinsic(unsigned ID) {
3715-
#if LLVM_VERSION_MAJOR >= 12
37163696
switch (ID) {
37173697
default:
37183698
break;
@@ -3725,7 +3705,6 @@ static GenXIntrinsic::ID convertMinMaxIntrinsic(unsigned ID) {
37253705
case Intrinsic::umax:
37263706
return GenXIntrinsic::genx_umax;
37273707
};
3728-
#endif
37293708
IGC_ASSERT_EXIT_MESSAGE(0, "unknown min/max intrinsic");
37303709
return GenXIntrinsic::not_any_intrinsic;
37313710
}

IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ class GenXPatternMatch : public FunctionPass,
163163

164164
void visitUDiv(BinaryOperator &I);
165165

166-
#if LLVM_VERSION_MAJOR >= 10
167166
void visitFreezeInst(FreezeInst &I);
168-
#endif
169167

170168
bool runOnFunction(Function &F) override;
171169

@@ -3387,14 +3385,12 @@ void GenXPatternMatch::visitURem(BinaryOperator &I) {
33873385
return decomposeURemPow2(I);
33883386
}
33893387

3390-
#if LLVM_VERSION_MAJOR >= 10
3391-
// Quick fix of IGC LLVM 11 based compilation failures.
3388+
// Clean up 'freeze' instances once dependent w/a's have been resolved.
33923389
void GenXPatternMatch::visitFreezeInst(FreezeInst &I) {
33933390
Value *Op = I.getOperand(0);
33943391
I.replaceAllUsesWith(Op);
33953392
Changed = true;
33963393
}
3397-
#endif
33983394

33993395
// Decompose predicate operand for large vector selects.
34003396
bool GenXPatternMatch::decomposeSelect(Function *F) {

IGC/VectorCompiler/lib/GenXCodeGen/GenXPromotePredicate.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,17 @@ struct Comparator {
274274

275275
bool GenXPromotePredicate::runOnFunction(Function &F) {
276276
// Put every predicate instruction into its own equivalence class.
277-
#if LLVM_VERSION_MAJOR > 13
278277
long Idx = 0;
279-
llvm::EquivalenceClasses<Instruction *, Comparator>
280-
#else
281-
llvm::EquivalenceClasses<Instruction *>
282-
#endif
283-
PredicateWebs;
278+
llvm::EquivalenceClasses<Instruction *, Comparator> PredicateWebs;
284279
for (auto &I : instructions(F)) {
285280
if (!genx::isPredicate(&I))
286281
continue;
287282
if (!I.isBitwiseLogicOp() && !isa<PHINode>(&I))
288283
continue;
289-
#if LLVM_VERSION_MAJOR > 13
290284
auto &Ctx = I.getContext();
291285
auto *MD = ConstantAsMetadata::get(
292286
ConstantInt::get(Ctx, llvm::APInt(64, ++Idx, false)));
293287
I.setMetadata(IdxMDName, MDNode::get(Ctx, MD));
294-
#endif
295288
PredicateWebs.insert(&I);
296289
}
297290
// Connect data-flow related instructions together.
@@ -300,12 +293,7 @@ bool GenXPromotePredicate::runOnFunction(Function &F) {
300293
for (auto &Op : Inst->operands()) {
301294
Instruction *In = dyn_cast<Instruction>(Op);
302295

303-
if (!In ||
304-
#if LLVM_VERSION_MAJOR > 13
305-
!In->hasMetadata(IdxMDName))
306-
#else
307-
PredicateWebs.findValue(In) == PredicateWebs.end())
308-
#endif
296+
if (!In || !In->hasMetadata(IdxMDName))
309297
continue;
310298
PredicateWebs.unionSets(Inst, In);
311299
}

IGC/VectorCompiler/lib/GenXCodeGen/GenXSimdCFRegion.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -702,25 +702,15 @@ bool GenXPredToSimdCF::isReduceAnd(const Value *V) {
702702
if (V)
703703
if (const CallInst *CI = dyn_cast<CallInst>(V))
704704
return GenXIntrinsic::getGenXIntrinsicID(V) == GenXIntrinsic::genx_all ||
705-
CI->getIntrinsicID() ==
706-
#if LLVM_VERSION_MAJOR < 12
707-
Intrinsic::experimental_vector_reduce_and;
708-
#else
709-
Intrinsic::vector_reduce_and;
710-
#endif
705+
CI->getIntrinsicID() == Intrinsic::vector_reduce_and;
711706
return false;
712707
}
713708

714709
bool GenXPredToSimdCF::isReduceOr(const Value *V) {
715710
if (V)
716711
if (const CallInst *CI = dyn_cast<CallInst>(V))
717712
return GenXIntrinsic::getGenXIntrinsicID(V) == GenXIntrinsic::genx_any ||
718-
CI->getIntrinsicID() ==
719-
#if LLVM_VERSION_MAJOR < 12
720-
Intrinsic::experimental_vector_reduce_or;
721-
#else
722-
Intrinsic::vector_reduce_or;
723-
#endif
713+
CI->getIntrinsicID() == Intrinsic::vector_reduce_or;
724714
return false;
725715
}
726716

IGC/VectorCompiler/lib/GenXCodeGen/GenXSubtarget.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ void GenXSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
7171
if (CPUName.empty() || TargetId == Invalid)
7272
report_fatal_error("Undefined or blank arch passed");
7373

74-
ParseSubtargetFeatures(CPUName,
75-
#if LLVM_VERSION_MAJOR >= 12
76-
/*TuneCPU=*/CPUName,
77-
#endif
78-
FS);
74+
ParseSubtargetFeatures(CPUName, /*TuneCPU=*/CPUName, FS);
7975
if (EnforceLongLongEmulation)
8076
EmulateLongLong = true;
8177
if (EnforceDivRem32Emulation)
@@ -84,11 +80,7 @@ void GenXSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
8480

8581
GenXSubtarget::GenXSubtarget(const Triple &TT, const std::string &CPU,
8682
const std::string &FS)
87-
: GenXGenSubtargetInfo(TT, CPU,
88-
#if LLVM_VERSION_MAJOR >= 12
89-
/*TuneCPU=*/CPU,
90-
#endif
91-
FS),
83+
: GenXGenSubtargetInfo(TT, CPU, /*TuneCPU=*/CPU, FS),
9284
TargetTriple(TT) {
9385
initSubtargetFeatures(CPU, FS);
9486
}

0 commit comments

Comments
 (0)