Skip to content

Commit c2abde8

Browse files
jgu222igcbot
authored andcommitted
If an i64 value is used as call's argument more than once
(mul %1 %1), make sure that this value is only combined once.
1 parent de55301 commit c2abde8

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,18 +1884,30 @@ bool InstExpander::visitCall(CallInst& Call) {
18841884
auto* CallCopy = Call.clone();
18851885
IGC_ASSERT(nullptr != CallCopy);
18861886
CallCopy->insertBefore(&Call);
1887-
1888-
// All int64 operands shall be recreated right before CallCopy
18891887
IRB->SetInsertPoint(CallCopy);
1890-
unsigned argNo = 0;
1891-
for (auto& Op : Call.operands())
1888+
for (int argNo=0, sz = (int)Call.getNumArgOperands(); argNo < sz; ++argNo)
18921889
{
1893-
if (Emu->isInt64(Op.get()))
1890+
Value* OldVal = Call.getArgOperand(argNo);
1891+
if (Emu->isInt64(OldVal))
18941892
{
1895-
Value* NewVal = Combine2xi32Toi64(Op.get());
1893+
Value* NewVal = nullptr;
1894+
1895+
// If this operand has been combined (same value is used more than
1896+
// once. for example, mul %12 %12), do not recombine them.
1897+
for (int i = 0; i < argNo; ++i)
1898+
{
1899+
if (Call.getArgOperand(i) == OldVal)
1900+
{
1901+
NewVal = CallCopy->getOperand(i);
1902+
break;
1903+
}
1904+
}
1905+
if (NewVal == nullptr)
1906+
{
1907+
NewVal = Combine2xi32Toi64(OldVal);
1908+
}
18961909
CallCopy->setOperand(argNo, NewVal);
18971910
}
1898-
argNo++;
18991911
}
19001912

19011913
// For int64 return value, split it right after CallCopy

0 commit comments

Comments
 (0)