Skip to content

Commit 5e4a7b9

Browse files
authored
Drop preprocessor checks for unsupported LLVM versions (#23491)
Drop preprocessor checks for unsupported LLVM versions Delete all #if LLVM_VERSION_MAJOR checks which were about LLVM versions older than 14.
1 parent 47c1f6e commit 5e4a7b9

File tree

27 files changed

+5
-281
lines changed

27 files changed

+5
-281
lines changed

IGC/AdaptorCommon/FastMathConstantHandling.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void FastMathConstantHandling::visitInstruction(Instruction &I) {
7575
I.setHasNoSignedZeros(false);
7676
}
7777
}
78-
#if LLVM_VERSION_MAJOR >= 10
78+
7979
void FastMathConstantHandling::visitFNeg(Instruction &I) {
8080
auto *fp_val = dyn_cast<llvm::ConstantFP>(I.getOperand(0));
8181
if (fp_val && fp_val->getValueAPF().isZero()) {
@@ -85,7 +85,6 @@ void FastMathConstantHandling::visitFNeg(Instruction &I) {
8585
}
8686
}
8787
}
88-
#endif
8988

9089
void FastMathConstantHandling::visitFDiv(Instruction &I) {
9190
if (auto *fp_val = dyn_cast<llvm::ConstantFP>(I.getOperand(1)); fp_val && fp_val->getValueAPF().isZero()) {

IGC/AdaptorOCL/OCL/sp/spp_g8.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,10 @@ bool CGen8OpenCLProgram::GetZEBinary(llvm::raw_pwrite_stream &programBinary, uns
388388
}
389389
} else {
390390
linkErr.str(); // Flush contents to the associated string
391-
#if LLVM_VERSION_MAJOR >= 10
391+
392392
linkOut.str(); // Flush contents to the associated string
393393
linkErrStr.append(linkOutStr);
394-
#endif // LLVM_VERSION_MAJOR
394+
395395
if (!linkErrStr.empty()) {
396396
if (ctx) {
397397
ctx->EmitError(linkErrStr.c_str(), nullptr);

IGC/Compiler/CISACodeGen/GenIRLowering.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@ SPDX-License-Identifier: MIT
1919
#include <llvm/IR/IRBuilder.h>
2020
#include <llvm/IR/PatternMatch.h>
2121
#include <llvm/Analysis/ScalarEvolution.h>
22-
#if LLVM_VERSION_MAJOR < 11
23-
#include <llvm/Analysis/ScalarEvolutionExpander.h>
24-
#endif
2522
#include <llvm/Analysis/ScalarEvolutionExpressions.h>
2623
#include <llvm/Analysis/TargetFolder.h>
2724
#include <llvm/IR/GetElementPtrTypeIterator.h>
28-
#if LLVM_VERSION_MAJOR >= 11
2925
#include <llvm/Transforms/Utils/ScalarEvolutionExpander.h>
30-
#endif
3126
#include <llvm/Transforms/Utils/Local.h>
3227
#include "llvmWrapper/IR/Intrinsics.h"
3328
#include "llvmWrapper/IR/DerivedTypes.h"

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,11 +1293,9 @@ void CodeGenPatternMatch::visitUnaryInstruction(llvm::UnaryInstruction &I) {
12931293
case Instruction::Load:
12941294
match = MatchSingleInstruction(I);
12951295
break;
1296-
#if LLVM_VERSION_MAJOR >= 10
12971296
case Instruction::FNeg:
12981297
match = MatchAbsNeg(I);
12991298
break;
1300-
#endif
13011299
}
13021300
IGC_ASSERT(match);
13031301
}
@@ -1322,9 +1320,7 @@ void CodeGenPatternMatch::visitIntrinsicInst(llvm::IntrinsicInst &I) {
13221320
case Intrinsic::exp2:
13231321
match = MatchPow(I) || MatchModifier(I);
13241322
break;
1325-
#if LLVM_VERSION_MAJOR >= 12
13261323
case Intrinsic::abs:
1327-
#endif
13281324
case Intrinsic::fabs:
13291325
match = MatchAbsNeg(I);
13301326
break;
@@ -5256,13 +5252,11 @@ bool isAbs(llvm::Value *abs, e_modifier &mod, llvm::Value *&source) {
52565252
mod = EMOD_ABS;
52575253
return true;
52585254
}
5259-
#if LLVM_VERSION_MAJOR >= 12
52605255
if (intrinsicInst->getIntrinsicID() == Intrinsic::abs) {
52615256
source = intrinsicInst->getOperand(0);
52625257
mod = EMOD_ABS;
52635258
return true;
52645259
}
5265-
#endif
52665260
}
52675261

52685262
llvm::SelectInst *select = llvm::dyn_cast<llvm::SelectInst>(abs);
@@ -5363,13 +5357,11 @@ bool IsNegate(llvm::Instruction *inst, llvm::Value *&negateSource) {
53635357
return true;
53645358
}
53655359
}
5366-
#if LLVM_VERSION_MAJOR >= 10
53675360
UnaryOperator *unop = dyn_cast<UnaryOperator>(inst);
53685361
if (unop && inst->getOpcode() == Instruction::FNeg) {
53695362
negateSource = inst->getOperand(0);
53705363
return true;
53715364
}
5372-
#endif
53735365
return false;
53745366
}
53755367

IGC/Compiler/CISACodeGen/PromoteInt8Type.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,12 +619,10 @@ void PromoteInt8Type::promoteInstructions() {
619619
newVal = m_builder->CreateInsertElement(getSI16Value(v0), getSI16Value(v1), getUI16Value(v2), "b2s");
620620
break;
621621
}
622-
#if LLVM_VERSION_MAJOR >= 10
623622
case Instruction::Freeze: {
624623
newVal = m_builder->CreateFreeze(getSI16Value(v0), "b2s");
625624
break;
626625
}
627-
#endif
628626
default:
629627
IGC_ASSERT_MESSAGE(0, "Unexpected inst of i8");
630628
} // Switch

IGC/Compiler/CISACodeGen/ScalarizerCodeGen.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ void ScalarizerCodeGen::visitCastInst(llvm::CastInst &I) {
143143
}
144144
}
145145

146-
#if LLVM_VERSION_MAJOR >= 10
147146
void ScalarizerCodeGen::visitFNeg(llvm::UnaryOperator &I) {
148147
if (I.getType()->isVectorTy()) {
149148
IGCLLVM::FixedVectorType *InstType = cast<IGCLLVM::FixedVectorType>(I.getType());
@@ -164,4 +163,3 @@ void ScalarizerCodeGen::visitFNeg(llvm::UnaryOperator &I) {
164163
I.eraseFromParent();
165164
}
166165
}
167-
#endif

IGC/Compiler/CISACodeGen/ScalarizerCodeGen.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ class ScalarizerCodeGen : public llvm::FunctionPass, public llvm::InstVisitor<Sc
2626
virtual bool runOnFunction(llvm::Function &F);
2727
void visitBinaryOperator(llvm::BinaryOperator &I);
2828
void visitCastInst(llvm::CastInst &I);
29-
#if LLVM_VERSION_MAJOR >= 10
3029
void visitFNeg(llvm::UnaryOperator &I);
31-
#endif
3230

3331
private:
3432
llvm::IRBuilder<> *m_builder = nullptr;

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -658,18 +658,6 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature
658658
if (!isOptDisabled && ctx.m_instrTypes.hasLoadStore && IGC_IS_FLAG_DISABLED(DisableMemOpt) &&
659659
!ctx.getModuleMetaData()->disableMemOptforNegativeOffsetLoads) {
660660

661-
#if LLVM_VERSION_MAJOR <= 10
662-
if (ctx.type == ShaderType::OPENCL_SHADER) {
663-
// Some LLVM passes may produce load/store instructions without alignment set,
664-
// for example SROA. LLVM API has been changed to ensure that alignment is never
665-
// missing, it has been changed in LLVM11: https://reviews.llvm.org/D77454.
666-
// Merging loads/stores without alignment set results in producing loads/stores
667-
// that operate on a bigger types, hence loosing an information about actual alignment.
668-
// AlignmentAnalysis restores alignments based on data-flow analysis, so that MemOpt
669-
// can propagate the correct alignment to the merged instructions.
670-
mpm.add(new AlignmentAnalysis());
671-
}
672-
#endif
673661

674662
if ((ctx.type == ShaderType::RAYTRACING_SHADER || ctx.hasSyncRTCalls()) &&
675663
IGC_IS_FLAG_DISABLED(DisablePrepareLoadsStores)) {
@@ -736,20 +724,9 @@ void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager &mpm, PSSignature
736724

737725
const bool allowIPConstProp = !ctx.m_hasStackCalls && IGC_IS_FLAG_DISABLED(DisableIPConstantPropagation);
738726

739-
#if LLVM_VERSION_MAJOR >= 12
740727
if (allowIPConstProp) {
741728
mpm.add(createIPSCCPPass());
742729
}
743-
// Note / todo: LLVM < 12 also runs simple constant propagation pass regardless
744-
// of IPSCCP in this case.
745-
// This pass is not available on >= 12 version, but maybe SCCP pass would
746-
// be suitable here.
747-
#else
748-
if (allowIPConstProp) {
749-
mpm.add(createIPConstantPropagationPass());
750-
}
751-
mpm.add(createConstantPropagationPass());
752-
#endif
753730

754731
mpm.add(createDeadCodeEliminationPass());
755732
mpm.add(createCFGSimplificationPass());
@@ -1189,19 +1166,12 @@ void OptimizeIR(CodeGenContext *const pContext) {
11891166
// Don't run IPConstantProp if there are stackcalls
11901167
const bool allowIPConstProp = !pContext->m_hasStackCalls && IGC_IS_FLAG_DISABLED(DisableIPConstantPropagation);
11911168

1192-
#if LLVM_VERSION_MAJOR >= 12
11931169
if (allowIPConstProp) {
11941170
mpm.add(createIPSCCPPass());
11951171
}
11961172
// Note / todo: LLVM < 12 also runs simple constant propagation pass
11971173
// regardless of IPSCCP in this case. This pass is not available on
11981174
// >= 12 version, but maybe SCCP pass would be suitable here.
1199-
#else
1200-
mpm.add(createConstantPropagationPass());
1201-
if (allowIPConstProp) {
1202-
mpm.add(createIPConstantPropagationPass());
1203-
}
1204-
#endif
12051175
}
12061176
if (IGC_IS_FLAG_ENABLED(MSAA16BitPayloadEnable) && pContext->platform.support16bitMSAAPayload()) {
12071177
mpm.add(new ConvertMSAAPayloadTo16Bit());
@@ -1224,11 +1194,7 @@ void OptimizeIR(CodeGenContext *const pContext) {
12241194
mpm.add(new HoistCongruentPHI());
12251195
mpm.add(new CodeSinking());
12261196
}
1227-
#if LLVM_VERSION_MAJOR >= 12
12281197
mpm.add(llvm::createCFGSimplificationPass(SimplifyCFGOptions().hoistCommonInsts(true)));
1229-
#else
1230-
mpm.add(llvm::createCFGSimplificationPass());
1231-
#endif
12321198

12331199
mpm.add(llvm::createBasicAAWrapperPass());
12341200
mpm.add(createAddressSpaceAAWrapperPass());
@@ -1461,7 +1427,6 @@ void OptimizeIR(CodeGenContext *const pContext) {
14611427

14621428
mpm.add(new BreakConstantExpr());
14631429
mpm.add(new IGCConstProp(IGC_IS_FLAG_ENABLED(EnableSimplifyGEP)));
1464-
#if LLVM_VERSION_MAJOR >= 14
14651430
// Now that constant propagation is largely complete, perform
14661431
// initial evaluation of freeze instructions. We need this to make
14671432
// life easier for subsequent LLVM passes, as passes like
@@ -1471,7 +1436,6 @@ void OptimizeIR(CodeGenContext *const pContext) {
14711436
// TODO: Check if LLVM 15+ provides improvements in that regard,
14721437
// alleviating the need for early freeze evaluation.
14731438
mpm.add(createEvaluateFreezePass());
1474-
#endif // LLVM_VERSION_MAJOR
14751439

14761440
if (IGC_IS_FLAG_DISABLED(DisableImmConstantOpt)) {
14771441
// If we have ICBs, need to emit clamp code so OOB access doesn't occur
@@ -1506,7 +1470,7 @@ void OptimizeIR(CodeGenContext *const pContext) {
15061470
// We need to increase default duplication threshold since JumpThreading pass cost estimation does
15071471
// not consider that not all instructions need to be duplicated.
15081472
int BBDuplicateThreshold = (pContext->type == ShaderType::OPENCL_SHADER) ? 9 : -1;
1509-
#if LLVM_VERSION_MAJOR >= 15 || LLVM_VERSION_MAJOR < 12
1473+
#if LLVM_VERSION_MAJOR >= 15
15101474
// In LLVM-12.x an extra parameter InsertFreezeWhenUnfoldingSelect = false was added
15111475
// to JumpThreading pass, but since LLVM-15.x it was removed again.
15121476
mpm.add(llvm::createJumpThreadingPass(BBDuplicateThreshold));

IGC/Compiler/CISACodeGen/WIAnalysis.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,10 @@ void WIAnalysisRunner::calculate_dep(const Value *val) {
737737
dep = calculate_dep(LI);
738738
else if (const VAArgInst *VAI = dyn_cast<VAArgInst>(inst))
739739
dep = calculate_dep(VAI);
740-
#if LLVM_VERSION_MAJOR >= 10
741740
else if (inst->getOpcode() == Instruction::FNeg)
742741
dep = calculate_dep_simple(inst);
743742
else if (inst->getOpcode() == Instruction::Freeze)
744743
dep = calculate_dep_simple(inst);
745-
#endif
746744

747745
if (m_func->hasFnAttribute("KMPLOCK")) {
748746
dep = WIAnalysis::UNIFORM_THREAD;

IGC/Compiler/CISACodeGen/opCode.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,11 @@ DECLARE_OPCODE(Alloca, Instruction, llvm_alloca, false, false, false, false, fal
171171
DECLARE_OPCODE(FPExt, Instruction, llvm_fpext, true, false, false, false, false, false, false)
172172
DECLARE_OPCODE(GenISA_f32tof16_rtz, GenISAIntrinsic, llvm_f32tof16_rtz, true, false, false, false, true, false, false)
173173
DECLARE_OPCODE(fabs, Intrinsic, llvm_fabs, false, false, true, false, true, false, false)
174-
#if LLVM_VERSION_MAJOR >= 12
175174
DECLARE_OPCODE(abs, Intrinsic, llvm_abs, false, false, true, false, true, false, false)
176175
DECLARE_OPCODE(smin, Intrinsic, llvm_smin, false, false, true, false, true, false, false)
177176
DECLARE_OPCODE(smax, Intrinsic, llvm_smax, false, false, true, false, true, false, false)
178177
DECLARE_OPCODE(umin, Intrinsic, llvm_umin, false, false, true, false, true, false, false)
179178
DECLARE_OPCODE(umax, Intrinsic, llvm_umax, false, false, true, false, true, false, false)
180-
#endif
181179
DECLARE_OPCODE(GenISA_fsat, GenISAIntrinsic, llvm_fsat, true, false, true, true, true, false, false)
182180
DECLARE_OPCODE(canonicalize, Intrinsic, llvm_canonicalize, true, true, true, true, false, false, false)
183181
DECLARE_OPCODE(GenISA_dp4a_ss, GenISAIntrinsic, llvm_dp4a_ss, false, true, true, true, false, false, false)

0 commit comments

Comments
 (0)