Skip to content

Commit

Permalink
[Autobackout][FunctionalRegression]Revert of change: ec4c755: Regener…
Browse files Browse the repository at this point in the history
…ate tests/ScalarizeFunction/selective.ll (NFCI)

Use update_test_checks.py to generate the checks for the test.
    This simplifies adding new tests or updating the existing ones.
  • Loading branch information
sys-igc authored and igcbot committed Sep 4, 2024
1 parent b4a8369 commit 9ebe19f
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 232 deletions.
3 changes: 2 additions & 1 deletion IGC/AdaptorOCL/UnifyIROCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ static void CommonOCLBasedPasses(

mpm.add(new ScalarArgAsPointerAnalysis());

mpm.add(createScalarizerPass(SelectiveScalarizer::Auto));
// true means selective scalarization
mpm.add(createScalarizerPass(IGC_IS_FLAG_ENABLED(EnableSelectiveScalarizer)));

// Create a dummy kernel to attach the symbol table if necessary
// Only needed if function pointers, externally linked functions, or relocatable global variables are present
Expand Down
56 changes: 13 additions & 43 deletions IGC/Compiler/Optimizer/Scalarizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,24 @@ IGC_INITIALIZE_PASS_END(ScalarizeFunction, PASS_FLAG, PASS_DESCRIPTION, PASS_CFG

char ScalarizeFunction::ID = 0;

ScalarizeFunction::ScalarizeFunction(IGC::SelectiveScalarizer selectiveMode) : FunctionPass(ID)
ScalarizeFunction::ScalarizeFunction(bool selectiveScalarization) : FunctionPass(ID)
{
initializeScalarizeFunctionPass(*PassRegistry::getPassRegistry());

for (int i = 0; i < Instruction::OtherOpsEnd; i++) m_transposeCtr[i] = 0;

V_PRINT(scalarizer, "ScalarizeFunction constructor\n");
switch(selectiveMode) {
case IGC::SelectiveScalarizer::Off:
V_PRINT(scalarizer, "IGC_EnableSelectiveScalarizer forced off");
m_SelectiveScalarization = false;
break;
case IGC::SelectiveScalarizer::On:
V_PRINT(scalarizer, "IGC_EnableSelectiveScalarizer forced on");
m_SelectiveScalarization = true;
break;
case IGC::SelectiveScalarizer::Auto:
V_PRINT(scalarizer, "IGC_EnableSelectiveScalarizer = ");
V_PRINT(scalarizer, IGC_IS_FLAG_ENABLED(EnableSelectiveScalarizer));
m_SelectiveScalarization = IGC_IS_FLAG_ENABLED(EnableSelectiveScalarizer);
break;
}
V_PRINT(scalarizer, "\n");
// Needs IGC_EnableSelectiveScalarizer = 1
m_SelectiveScalarization = selectiveScalarization;

// Initialize SCM buffers and allocation
m_SCMAllocationArray = new SCMEntry[ESTIMATED_INST_NUM];
m_SCMArrays.push_back(m_SCMAllocationArray);
m_SCMArrayLocation = 0;

V_PRINT(scalarizer, "ScalarizeFunction constructor\n");
V_PRINT(scalarizer, "IGC_EnableSelectiveScalarizer = ");
V_PRINT(scalarizer, IGC_IS_FLAG_ENABLED(EnableSelectiveScalarizer));
V_PRINT(scalarizer, "\n");
}

bool ScalarizeFunction::doFinalization(llvm::Module& M) {
Expand Down Expand Up @@ -254,40 +244,20 @@ void ScalarizeFunction::buildExclusiveSet()
}
else if (BitCastInst* BCI = dyn_cast<BitCastInst>(currInst))
{
auto isBitcastSink = [](BitCastInst *BCI) -> bool {
auto *SrcVTy = dyn_cast<IGCLLVM::FixedVectorType>(
BCI->getOperand(0)->getType());

// If source is not a vector, we don't care about this bitcast
if (!SrcVTy)
return false;

// If destination is a vector then we scalarize if the number of
// elements are the same (elementwise bitcast)
if (auto *DestVTy =
dyn_cast<IGCLLVM::FixedVectorType>(BCI->getType()))
return DestVTy->getNumElements() != SrcVTy->getNumElements();

// If destination is not a vector, we don't want to scalarize
return true;
};

if (isBitcastSink(BCI)) {
workset.push_back(BCI->getOperand(0));
}
}
// try to find a web from the seed
std::set<Value*> defweb;
while (!workset.empty())
{
auto* Def = workset.back();
auto Def = workset.back();
workset.pop_back();
if (m_Excludes.count(Def) || defweb.count(Def))
{
continue;
}

// The web grows "up" (towards producers) through BitCasts and PHI nodes
// The web grows "up" through BitCasts and PHI nodes
// but insert/extract elements and vector shuffles should be scalarized
if (!isAddToWeb(Def)) continue;

Expand Down Expand Up @@ -315,7 +285,7 @@ void ScalarizeFunction::buildExclusiveSet()
continue;
}

// The web grows "down" (towards users) through BitCasts and PHI nodes as well
// The web grows "down" through BitCasts and PHI nodes as well
for (auto U : Def->users())
{
if (!defweb.count(U) && isAddToWeb(U))
Expand Down Expand Up @@ -1488,8 +1458,8 @@ void ScalarizeFunction::resolveDeferredInstructions()
m_DRL.clear();
}

extern "C" FunctionPass * createScalarizerPass(IGC::SelectiveScalarizer selectiveMode)
extern "C" FunctionPass * createScalarizerPass(bool selectiveScalarization)
{
return new ScalarizeFunction(selectiveMode);
return new ScalarizeFunction(selectiveScalarization);
}

15 changes: 3 additions & 12 deletions IGC/Compiler/Optimizer/Scalarizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ namespace IGC
// Define estimated amount of instructions in function
#define ESTIMATED_INST_NUM 128

enum class SelectiveScalarizer {
Off,
On,
Auto ///< Based on IGC_EnableSelectiveScalarizer (0 = off, 1 = on)
};

/// @brief Scalarization pass used for converting code in functions
/// which operate on vector types, to work on scalar types (by breaking
/// data elements to scalars, and breaking each vector operation
Expand All @@ -57,10 +51,7 @@ namespace IGC
public:
static char ID; // Pass identification, replacement for typeid

// Default value differs from createScalarizerPass to allow control over selective
// scalarization when pass is directly called from the command line (via igc_opt).
ScalarizeFunction(
SelectiveScalarizer selectiveMode = IGC::SelectiveScalarizer::Auto);
ScalarizeFunction(bool selectiveScalarization = true);
ScalarizeFunction(const ScalarizeFunction&) = delete;
ScalarizeFunction& operator=(const ScalarizeFunction&) = delete;

Expand Down Expand Up @@ -280,5 +271,5 @@ namespace IGC
/// The ending legs of the web consist of vectorial instructions such as insert and extract elements,
/// vector shuffles, GenISA intrinsics and function calls.
/// The vectorial instructions inside the web consist of bitcasts and PHI nodes.
extern "C" llvm::FunctionPass *createScalarizerPass(
IGC::SelectiveScalarizer selectiveMode = IGC::SelectiveScalarizer::Off);
extern "C" llvm::FunctionPass * createScalarizerPass(bool selectiveScalarization = false);

Loading

0 comments on commit 9ebe19f

Please sign in to comment.