Skip to content

Commit 9d0fd2a

Browse files
dlei6gsys_zuul
authored andcommitted
[Autobackout]Revert of change: 9fe158e
- Enforce immediate value constraint for inline asm. - Fixed a bug where the source of an inline asm call with multiple outputs was not being matched in PatternMatchPass. - Fixed an issue where LLVM promotes a variable to a constant, causing an immediate value to be written to the asm string when it should not be. __asm__ ("mov (M1, 16) %0(0,0)<1> %1(0,0)<1;1,0>" : "=rw" (s1) : "rw" (s2) ); When s2 is promoted to a constant value, the following vISA instruction is generated. The immediate value still contains the regioning info from the user inlined string. mov (M1, 16) V39(0,0)<1> 0x3f800000:f(0,0)<1;1,0> By enforcing the constraint, if we detect an immediate value with the "rw" constraint, we can generate an extra move instruction to resolve this issue. Change-Id: Ia4229684d20714c0980106ff39db93eb1aa156e0
1 parent abc9da6 commit 9d0fd2a

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8140,8 +8140,6 @@ void EmitPass::EmitInlineAsm(llvm::CallInst* inst)
81408140
opnds.push_back(cv);
81418141
}
81428142

8143-
assert(opnds.size() == constraints.size());
8144-
81458143
// Check for read/write registers
81468144
if (!inst->getType()->isVoidTy())
81478145
{
@@ -8162,20 +8160,6 @@ void EmitPass::EmitInlineAsm(llvm::CallInst* inst)
81628160
}
81638161
}
81648162

8165-
// Special handling if LLVM replaces a variable with an immediate, we need to insert an extra move
8166-
for (unsigned i = 0; i < opnds.size(); i++)
8167-
{
8168-
CVariable* opVar = opnds[i];
8169-
StringRef constraint = constraints[i];
8170-
if (opVar->IsImmediate() && !constraint.equals("i"))
8171-
{
8172-
CVariable* tempMov = m_currShader->GetNewVariable(1, opVar->GetType(), EALIGN_GRF, true);
8173-
m_encoder->Copy(tempMov, opVar);
8174-
m_encoder->Push();
8175-
opnds[i] = tempMov;
8176-
}
8177-
}
8178-
81798163
str << endl << "/// Inlined ASM" << endl;
81808164
// Look for variables to replace with the VISA variable
81818165
size_t startPos = 0;

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,20 +1349,18 @@ namespace IGC
13491349
bool Match = false;
13501350

13511351
// Ignore the extract value instruction. Handled in the call inst.
1352+
bool isExtractFromInlineAsm = false;
13521353
if (CallInst * call = dyn_cast<CallInst>(I.getOperand(0)))
13531354
{
1354-
if (call->isInlineAsm() && call->getType()->isStructTy())
1355-
{
1356-
MarkAsSource(call);
1357-
return;
1358-
}
1355+
isExtractFromInlineAsm = call->isInlineAsm() && call->getType()->isStructTy();
13591356
}
13601357

1361-
Match = matchAddPair(&I) ||
1358+
Match = isExtractFromInlineAsm ||
1359+
MatchCopyFromStruct(&I) ||
1360+
matchAddPair(&I) ||
13621361
matchSubPair(&I) ||
13631362
matchMulPair(&I) ||
1364-
matchPtrToPair(&I) ||
1365-
MatchCopyFromStruct(&I);
1363+
matchPtrToPair(&I);
13661364

13671365
assert(Match && "Unknown `extractvalue` instruction!");
13681366
}

0 commit comments

Comments
 (0)