Skip to content

Commit 8e03e13

Browse files
scottp101sys_zuul
authored andcommitted
Pull out the OPENCL_SHADER check as a pass option.
Change-Id: Iaf2520bf450cc7e1311ffeb030dbc6e3fde07160
1 parent 7298943 commit 8e03e13

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

IGC/Compiler/CISACodeGen/MemOpt.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ namespace {
8080
CodeGenContext* CGC;
8181
TargetLibraryInfo* TLI;
8282

83+
bool AllowNegativeSymPtrsForLoad = false;
84+
8385
// Map of profit vector lengths per scalar type. Each entry specifies the
8486
// profit vector length of a given scalar type.
8587
// NOTE: Prepare the profit vector lengths in the *DESCENDING* order.
@@ -94,9 +96,9 @@ namespace {
9496
public:
9597
static char ID;
9698

97-
MemOpt() :
99+
MemOpt(bool AllowNegativeSymPtrsForLoad = false) :
98100
FunctionPass(ID), DL(nullptr), AA(nullptr), SE(nullptr), WI(nullptr),
99-
CGC(nullptr) {
101+
CGC(nullptr), AllowNegativeSymPtrsForLoad(AllowNegativeSymPtrsForLoad) {
100102
initializeMemOptPass(*PassRegistry::getPassRegistry());
101103
}
102104

@@ -354,8 +356,8 @@ namespace {
354356
};
355357
}
356358

357-
FunctionPass* createMemOptPass() {
358-
return new MemOpt();
359+
FunctionPass* createMemOptPass(bool AllowNegativeSymPtrsForLoad) {
360+
return new MemOpt(AllowNegativeSymPtrsForLoad);
359361
}
360362

361363
#define PASS_FLAG "igc-memopt"
@@ -616,8 +618,7 @@ bool MemOpt::mergeLoad(LoadInst* LeadingLoad,
616618
continue;
617619
}
618620
else {
619-
if (CGC->type != ShaderType::OPENCL_SHADER &&
620-
LeadingSymPtr.Offset < 0)
621+
if (!AllowNegativeSymPtrsForLoad && LeadingSymPtr.Offset < 0)
621622
continue;
622623
}
623624
}

IGC/Compiler/CISACodeGen/MemOpt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5252
#include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
5353

5454
void initializeMemOptPass(llvm::PassRegistry&);
55-
llvm::FunctionPass* createMemOptPass();
55+
llvm::FunctionPass* createMemOptPass(bool AllowNegativeSymPtrsForLoad);
5656

5757
#endif // _CISA_MEMOPT_H_

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,9 @@ namespace IGC
508508
ctx.m_instrTypes.hasLoadStore && IGC_IS_FLAG_DISABLED(DisableMemOpt)) {
509509
if (IGC_IS_FLAG_ENABLED(EnableAdvMemOpt))
510510
mpm.add(createAdvMemOptPass());
511-
mpm.add(createMemOptPass());
511+
bool AllowNegativeSymPtrsForLoad =
512+
ctx.type == ShaderType::OPENCL_SHADER;
513+
mpm.add(createMemOptPass(AllowNegativeSymPtrsForLoad));
512514
mpm.add(createIGCInstructionCombiningPass());
513515
}
514516

0 commit comments

Comments
 (0)