Skip to content

Commit 387415a

Browse files
weiyu-chensys_zuul
authored andcommitted
Use int copy instead of float copy during spill code generation.
Change-Id: Ibfe337ecde398ef55ba90c6757507ef870a8dc60
1 parent ee6413f commit 387415a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

visa/G4_Opcode.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,25 @@ inline bool isLowPrecisionFloatTy(G4_Type ty)
421421
return ty == Type_HF;
422422
}
423423

424+
inline G4_Type floatToSameWidthIntType(G4_Type floatTy)
425+
{
426+
assert(IS_TYPE_FLOAT_ALL(floatTy));
427+
switch (getTypeSize(floatTy))
428+
{
429+
case 1:
430+
return Type_UB;
431+
case 2:
432+
return Type_UW;
433+
case 4:
434+
return Type_UD;
435+
case 8:
436+
return Type_UQ;
437+
default:
438+
assert(false && "illegal type size");
439+
return Type_UD;
440+
}
441+
}
442+
424443
#define GRFALIGN (Sixteen_Word)
425444
#define HALFGRFALIGN (Eight_Word)
426445
#endif // _G4_OPCODE_H_

visa/SpillManagerGMRF.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3260,9 +3260,17 @@ SpillManagerGRF::insertSpillRangeCode (
32603260
((*spilledInstIter)->opcode() != G4_sel)?
32613261
(*spilledInstIter)->getPredicate () : nullptr;
32623262

3263+
if (tmpRangeSrcRegion->getType() == spillRangeDstRegion->getType() && IS_TYPE_FLOAT_ALL(tmpRangeSrcRegion->getType()))
3264+
{
3265+
// use int copy when possible as floating-point copy moves may need further legalization
3266+
auto equivIntTy = floatToSameWidthIntType(tmpRangeSrcRegion->getType());
3267+
tmpRangeSrcRegion->setType(equivIntTy);
3268+
spillRangeDstRegion->setType(equivIntTy);
3269+
}
3270+
32633271
createMovInst (
32643272
execSize, spillRangeDstRegion, tmpRangeSrcRegion,
3265-
predicate != nullptr ? builder_->duplicateOperand(predicate) : predicate,
3273+
builder_->duplicateOperand(predicate),
32663274
(*spilledInstIter)->getMaskOption());
32673275
numGRFMove ++;
32683276

0 commit comments

Comments
 (0)