@@ -88,20 +88,21 @@ bool BUNDLE_INFO::doMerge(IR_Builder& builder,
88
88
return false ;
89
89
}
90
90
91
- int roundDownPow2Size = (int )Round_Down_Pow2 (size);
92
- if (size > roundDownPow2Size)
91
+ if (size == 3 )
93
92
{
94
93
for (int pos = 0 , numSrc = inst[0 ]->getNumSrc (); pos < numSrc; ++pos)
95
94
{
96
95
if (srcPattern[pos] == OPND_PATTERN::CONTIGUOUS)
97
96
{
98
- // since we are rounding up esize to roundUpPow2Size, we have to make sure the source is
99
- // not out of bound. To make it safe, we merge the first roundDownPow2Size insts instead.
100
- while (size > roundDownPow2Size)
97
+ // since we are rounding up esize to 4, we have to make sure the source is
98
+ // not out of bound. If it is we merge the first two inst instead
99
+ G4_SrcRegRegion* lastSrc = inst[size - 1 ]->getSrc (pos)->asSrcRegRegion ();
100
+ if (lastSrc->getLeftBound () + lastSrc->getTypeSize () >=
101
+ lastSrc->getTopDcl ()->getByteSize ())
101
102
{
102
103
deleteLastInst ();
104
+ break ;
103
105
}
104
- break ;
105
106
}
106
107
}
107
108
}
@@ -367,7 +368,7 @@ static bool checkContiguous(
367
368
// the conditions are:
368
369
// -- arithmetic, logic, mov, math, or pseudo_mad instructions
369
370
// -- simd1, NoMask, no predicates or conditional modifier
370
- // -- dst must be direct GRF whose declare has no alias
371
+ // -- dst must be direct GRF whose declare is a single element without alias
371
372
// -- all sources must be either direct GRF or immediates
372
373
bool BUNDLE_INFO::isMergeCandidate (G4_INST* inst, const IR_Builder& builder, bool isInSimdFlow)
373
374
{
@@ -408,6 +409,7 @@ bool BUNDLE_INFO::isMergeCandidate(G4_INST* inst, const IR_Builder& builder, boo
408
409
G4_Declare* dstDcl = dstBase->isRegVar () ? dstBase->asRegVar ()->getDeclare () : nullptr ;
409
410
if (dstDcl != nullptr &&
410
411
(dstDcl->getAliasDeclare () != nullptr ||
412
+ dstDcl->getTotalElems () != 1 ||
411
413
inst->getDst ()->getTypeSize () != dstDcl->getElemSize () ||
412
414
!dstDcl->useGRF ()))
413
415
{
0 commit comments