Skip to content

Commit a6fda9e

Browse files
esukhovigcbot
authored andcommitted
FADD vector emission is added
VISA emitter now can process vectorized fadd instructions.
1 parent 9239d02 commit a6fda9e

File tree

4 files changed

+542
-0
lines changed

4 files changed

+542
-0
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4383,6 +4383,9 @@ void EmitPass::BinaryUnary(llvm::Instruction* inst, const SSource source[2], con
43834383
case Instruction::FMul:
43844384
Mul(source, modifier);
43854385
break;
4386+
case Instruction::FAdd:
4387+
Add(source, modifier);
4388+
break;
43864389
case Instruction::Call:
43874390
EmitAluIntrinsic(cast<CallInst>(inst), source, modifier);
43884391
break;
@@ -4637,6 +4640,44 @@ void EmitPass::FPTrunc(const SSource sources[2], const DstModifier& modifier) {
46374640
}
46384641
}
46394642

4643+
4644+
void EmitPass::Add(const SSource sources[2], const DstModifier& modifier)
4645+
{
4646+
CVariable* src[2];
4647+
for (int i = 0; i < 2; ++i)
4648+
{
4649+
src[i] = GetSrcVariable(sources[i]);
4650+
}
4651+
4652+
if (IGC_IS_FLAG_ENABLED(EnableVectorEmitter) && sources[0].value->getType()->isVectorTy() && sources[1].value->getType()->isVectorTy()) {
4653+
4654+
unsigned int VectorSize = 0;
4655+
if (llvm::isa<Instruction>(sources[0].value))
4656+
VectorSize = getVectorSize(llvm::cast<Instruction>(sources[0].value));
4657+
4658+
for (unsigned int i = 0; i < VectorSize; ++i) {
4659+
SetSourceModifiers(0, sources[0]);
4660+
SetSourceModifiers(1, sources[1]);
4661+
4662+
if (src[0]->IsUniform())
4663+
m_encoder->SetSrcSubReg(0, i);
4664+
else
4665+
m_encoder->SetSrcSubVar(0, i);
4666+
if (src[1]->IsUniform())
4667+
m_encoder->SetSrcSubReg(1, i);
4668+
else
4669+
m_encoder->SetSrcSubVar(1, i);
4670+
4671+
m_encoder->SetDstSubVar(i);
4672+
m_encoder->Add(m_destination, src[0], src[1]);
4673+
m_encoder->Push();
4674+
}
4675+
return;
4676+
}
4677+
4678+
Binary(EOPCODE_ADD, sources, modifier);
4679+
}
4680+
46404681
void EmitPass::Mul(const SSource sources[2], const DstModifier& modifier)
46414682
{
46424683
CVariable* src[2];

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class EmitPass : public llvm::FunctionPass
101101
void Select(const SSource sources[3], const DstModifier& modifier);
102102
void PredAdd(const SSource& pred, bool invert, const SSource sources[2], const DstModifier& modifier);
103103
void Mul(const SSource[2], const DstModifier& modifier);
104+
void Add(const SSource[2], const DstModifier& modifier);
104105
void FPTrunc(const SSource[2], const DstModifier& modifier);
105106
void Powi(const SSource[2], const DstModifier& modifier);
106107
void Mov(const SSource& source, const DstModifier& modifier);

IGC/Compiler/CISACodeGen/IGCVectorizer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ bool isBinarySafe(Instruction *I) {
186186
if (Binary) {
187187
auto OpCode = Binary->getOpcode();
188188
Result |= OpCode == Instruction::FMul;
189+
Result |= OpCode == Instruction::FAdd;
189190
}
190191
return Result;
191192
}

0 commit comments

Comments
 (0)