Skip to content

Commit 7717667

Browse files
weiyu-chenZuul
authored andcommitted
Do not pattern match integer mad if one of mul operands is a constant int exceeding 16-bit.
Change-Id: I47f27a0df2c1b355de287e3779a05cf5e4a88088
1 parent ed25d37 commit 7717667

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,10 +2017,15 @@ namespace IGC
20172017
}
20182018

20192019
// Check integer mad profitability.
2020-
if (found && !isFpMad(I)) {
2020+
if (found && !isFpMad(I))
2021+
{
20212022
auto isByteOrWordValue = [](Value* V) -> bool {
2022-
if (isa<Constant>(V))
2023-
return true;
2023+
if (isa<ConstantInt>(V))
2024+
{
2025+
// only 16-bit int immediate is supported
2026+
APInt val = dyn_cast<ConstantInt>(V)->getValue();
2027+
return val.sge(SHRT_MIN) && val.sle(SHRT_MAX);
2028+
}
20242029
// Trace the def-use chain and return the first non up-cast related value.
20252030
while (isa<ZExtInst>(V) || isa<SExtInst>(V) || isa<BitCastInst>(V))
20262031
V = cast<Instruction>(V)->getOperand(0);

0 commit comments

Comments
 (0)