Commit 8950d5c2 authored by Chen, Weiyu's avatar Chen, Weiyu Committed by gbsbuild

hoist immediate values in FMA out of loop

Change-Id: I8391c190fef1901527ef78bb9a469fb6ad7d0d70
parent e8c54797
......@@ -1609,8 +1609,16 @@ bool CodeGenPatternMatch::MatchFMA( llvm::IntrinsicInst& I )
FMAPattern *pattern = new (m_allocator)FMAPattern();
for (int i = 0; i < 3; i++)
{
AddToConstantPool(I.getParent(), I.getOperand(i));
pattern->sources[i] = GetSource(I.getOperand(i), true, false);
llvm::Value* V = I.getOperand(i);
pattern->sources[i] = GetSource(V, true, false);
if (isa<Constant>(V) &&
(!m_Platform.support16BitImmSrcForMad() ||
V->getType()->getTypeID() != llvm::Type::HalfTyID || i == 1))
{
//CNL+ mad instruction allows 16 bit immediate for src0 and src2
AddToConstantPool(I.getParent(), V);
pattern->sources[i].fromConstantPool = true;
}
}
AddPattern(pattern);
......@@ -1706,13 +1714,13 @@ bool CodeGenPatternMatch::MatchMad( llvm::BinaryOperator& I )
{
MadPattern *pattern = new (m_allocator) MadPattern();
for(int i=0; i<3; i++)
{
//CNL+ mad instruction allows 16 bit immediate for src0 and src2
{
pattern->sources[i] = GetSource(sources[i], src_mod[i], false);
if (!m_Platform.support16BitImmSrcForMad() ||
(sources[i]->getType()->getTypeID() != llvm::Type::HalfTyID) ||
i == 1)
if (isa<Constant>(sources[i]) &&
(!m_Platform.support16BitImmSrcForMad() ||
(sources[i]->getType()->getTypeID() != llvm::Type::HalfTyID) || i == 1))
{
//CNL+ mad instruction allows 16 bit immediate for src0 and src2
AddToConstantPool(I.getParent(), sources[i]);
pattern->sources[i].fromConstantPool = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment