@@ -437,8 +437,8 @@ bool GenXLegalization::runOnFunction(Function &F) {
437437 Argument *Arg = &*fi;
438438 if (auto VT = dyn_cast<VectorType>(Arg->getType ()))
439439 if (VT->getElementType ()->isIntegerTy (1 ))
440- IGC_ASSERT (getPredPart (Arg, 0 ).Size == VT->getNumElements () &&
441- " function arg not allowed to be illegally sized predicate" );
440+ IGC_ASSERT_MESSAGE (getPredPart (Arg, 0 ).Size == VT->getNumElements (),
441+ " function arg not allowed to be illegally sized predicate" );
442442 }
443443
444444 // Legalize instructions. This does a postordered depth first traversal of the
@@ -556,7 +556,8 @@ unsigned GenXLegalization::getExecSizeAllowedBits(Instruction *Inst) {
556556bool GenXLegalization::checkIfLongLongSupportNeeded (Instruction *Inst) const {
557557 // for now, we expect that the inspected instruction results in a value
558558 // 64-bit type (scalar or vector)
559- IGC_ASSERT (Inst && Inst->getType ()->getScalarType ()->isIntegerTy (64 ));
559+ IGC_ASSERT (Inst);
560+ IGC_ASSERT (Inst->getType ()->getScalarType ()->isIntegerTy (64 ));
560561 auto CheckGenXIntrinsic = [](const Instruction *Inst) {
561562 // wrregion/rdregion by themselves should not require any HW support
562563 // since finalizer should handle the respected VISA mov instructions.
@@ -950,10 +951,15 @@ bool GenXLegalization::processBitCastFromPredicate(Instruction *Inst,
950951 unsigned SplitWidth = getPredPart (Pred, 0 ).Size ;
951952 if (SplitWidth == 0 )
952953 return false ;
953- #if _DEBUG
954- unsigned WholeWidth = cast<VectorType>(Pred->getType ())->getNumElements ();
955- IGC_ASSERT (!(WholeWidth % SplitWidth) && " does not handle odd predicate sizes" );
956- #endif
954+
955+ {
956+ unsigned WholeWidth = 0 ; // it will be assigned inside assertion statament
957+ IGC_ASSERT ((WholeWidth = cast<VectorType>(Pred->getType ())->getNumElements (), 1 ));
958+ IGC_ASSERT (SplitWidth);
959+ IGC_ASSERT_MESSAGE (!(WholeWidth % SplitWidth), " does not handle odd predicate sizes" );
960+ (void ) WholeWidth;
961+ }
962+
957963 // Bitcast each split predicate into an element of an int vector.
958964 // For example, if the split size is 16, then the result is a vector
959965 // of i16. Then bitcast that to the original result type.
@@ -999,7 +1005,8 @@ bool GenXLegalization::processBitCastToPredicate(Instruction *Inst,
9991005 Instruction *InsertBefore) {
10001006 unsigned WholeWidth = cast<VectorType>(Inst->getType ())->getNumElements ();
10011007 unsigned SplitWidth = getPredPart (Inst, 0 ).Size ;
1002- IGC_ASSERT (!(WholeWidth % SplitWidth) && " does not handle odd predicate sizes" );
1008+ IGC_ASSERT (SplitWidth);
1009+ IGC_ASSERT_MESSAGE (!(WholeWidth % SplitWidth), " does not handle odd predicate sizes" );
10031010 unsigned NumSplits = WholeWidth / SplitWidth;
10041011 if (NumSplits == 1 )
10051012 return false ;
@@ -1433,8 +1440,8 @@ unsigned GenXLegalization::determineNonRegionWidth(Instruction *Inst,
14331440 if (CallInst *CI = dyn_cast<CallInst>(Inst))
14341441 NumOperands = CI->getNumArgOperands ();
14351442 if (NumOperands) {
1436- IGC_ASSERT (isa<VectorType>(Inst->getOperand (0 )->getType ()) &&
1437- " instruction not supported" );
1443+ IGC_ASSERT_MESSAGE (isa<VectorType>(Inst->getOperand (0 )->getType ()),
1444+ " instruction not supported" );
14381445 unsigned InBytesPerElement =
14391446 cast<VectorType>(Inst->getOperand (0 )->getType ())
14401447 ->getElementType ()
@@ -1579,8 +1586,8 @@ class SplittableInsts {
15791586 HeadIt->Info .Type == BaleInfo::WRPREDPREDREGION)
15801587 End = HeadIt;
15811588 else {
1582- IGC_ASSERT (HeadIt->Info .Type != BaleInfo::GSTORE &&
1583- " GSTORE must have been considered before" );
1589+ IGC_ASSERT_MESSAGE (HeadIt->Info .Type != BaleInfo::GSTORE,
1590+ " GSTORE must have been considered before" );
15841591 End = SomeBale.end ();
15851592 }
15861593 }
@@ -1595,18 +1602,18 @@ class SplittableInsts {
15951602Value *GenXLegalization::joinBaleInsts (Value *PrevSliceRes, unsigned StartIdx,
15961603 unsigned Width,
15971604 Instruction *InsertBefore) {
1598- IGC_ASSERT (SplittableInsts (B).end () != B.end () &&
1599- " must have some instructions to join in the bale" );
1605+ IGC_ASSERT_MESSAGE (SplittableInsts (B).end () != B.end (),
1606+ " must have some instructions to join in the bale" );
16001607 if (B.endsWithGStore ()) {
1601- IGC_ASSERT (SplittableInsts (B).end () == B.getPreHeadIt () &&
1602- " a bale is considered to have only 1 dst, in case of GSTORE it's "
1603- " represented by the last 2 instructions" );
1608+ IGC_ASSERT_MESSAGE (SplittableInsts (B).end () == B.getPreHeadIt (),
1609+ " a bale is considered to have only 1 dst, in case of GSTORE it's "
1610+ " represented by the last 2 instructions" );
16041611 return joinGStore (PrevSliceRes, *B.getHead (), *B.getPreHead (), StartIdx,
16051612 Width, InsertBefore);
16061613 } else {
1607- IGC_ASSERT (SplittableInsts (B).end () == B.getHeadIt () &&
1608- " a bale is considered to have only 1 dst, in common case it's "
1609- " represented by the last instruction" );
1614+ IGC_ASSERT_MESSAGE (SplittableInsts (B).end () == B.getHeadIt (),
1615+ " a bale is considered to have only 1 dst, in common case it's "
1616+ " represented by the last instruction" );
16101617 return joinAnyWrRegion (PrevSliceRes, *B.getHead (), StartIdx, Width,
16111618 InsertBefore);
16121619 }
@@ -1624,11 +1631,13 @@ Value *GenXLegalization::joinBaleResult(Value *PrevSliceRes,
16241631 Value *LastSplitInst, unsigned StartIdx,
16251632 unsigned Width,
16261633 Instruction *InsertBefore) {
1627- IGC_ASSERT (PrevSliceRes && LastSplitInst && InsertBefore && " wrong arguments" );
1634+ IGC_ASSERT_MESSAGE (PrevSliceRes, " wrong argument" );
1635+ IGC_ASSERT_MESSAGE (LastSplitInst, " wrong argument" );
1636+ IGC_ASSERT_MESSAGE (InsertBefore, " wrong argument" );
16281637 auto Head = B.getHeadIgnoreGStore ()->Inst ;
16291638 auto VT = cast<VectorType>(Head->getType ());
1630- IGC_ASSERT (VT->getNumElements () != Width &&
1631- " there's no need to join results if they have the proper type" );
1639+ IGC_ASSERT_MESSAGE (VT->getNumElements () != Width,
1640+ " there's no need to join results if they have the proper type" );
16321641 if (VT->getElementType ()->isIntegerTy (1 )) {
16331642 auto NewWr = Region::createWrPredRegion (
16341643 PrevSliceRes, LastSplitInst, StartIdx,
@@ -1679,7 +1688,7 @@ Value *GenXLegalization::splitBale(Value *PrevSliceRes, unsigned StartIdx,
16791688 LastCreatedInst =
16801689 joinBaleInsts (PrevSliceRes, StartIdx, Width, InsertBefore);
16811690 else {
1682- IGC_ASSERT (LastCreatedInst && " must have at least some split inst" );
1691+ IGC_ASSERT_MESSAGE (LastCreatedInst, " must have at least some split inst" );
16831692 auto Head = B.getHeadIgnoreGStore ()->Inst ;
16841693 if (cast<VectorType>(Head->getType ())->getNumElements () != Width)
16851694 LastCreatedInst = joinBaleResult (PrevSliceRes, LastCreatedInst, StartIdx,
@@ -1694,7 +1703,7 @@ Value *GenXLegalization::splitBale(Value *PrevSliceRes, unsigned StartIdx,
16941703Value *GenXLegalization::joinGStore (Value *PrevSliceRes, BaleInst GStore,
16951704 BaleInst WrRegion, unsigned StartIdx,
16961705 unsigned Width, Instruction *InsertBefore) {
1697- IGC_ASSERT (GStore.Info .Type == BaleInfo::GSTORE && " wrong argument" );
1706+ IGC_ASSERT_MESSAGE (GStore.Info .Type == BaleInfo::GSTORE, " wrong argument" );
16981707 Value *Op =
16991708 joinAnyWrRegion (PrevSliceRes, WrRegion, StartIdx, Width, InsertBefore);
17001709 return new StoreInst (Op, GStore.Inst ->getOperand (1 ), /* volatile*/ true ,
@@ -1706,7 +1715,7 @@ Value *GenXLegalization::joinGStore(Value *PrevSliceRes, BaleInst GStore,
17061715Value *GenXLegalization::joinWrRegion (Value *PrevSliceRes, BaleInst BInst,
17071716 unsigned StartIdx, unsigned Width,
17081717 Instruction *InsertBefore) {
1709- IGC_ASSERT (BInst.Info .Type == BaleInfo::WRREGION && " wrong argument" );
1718+ IGC_ASSERT_MESSAGE (BInst.Info .Type == BaleInfo::WRREGION, " wrong argument" );
17101719 Region R (BInst.Inst , BInst.Info );
17111720 R.getSubregion (StartIdx, Width);
17121721 if (R.Mask && isa<VectorType>(R.Mask ->getType ()))
@@ -1739,7 +1748,7 @@ Value *GenXLegalization::joinPredPredWrRegion(Value *PrevSliceRes,
17391748 BaleInst BInst, unsigned StartIdx,
17401749 unsigned Width,
17411750 Instruction *InsertBefore) {
1742- IGC_ASSERT (BInst.Info .Type == BaleInfo::WRPREDPREDREGION && " wrong argument" );
1751+ IGC_ASSERT_MESSAGE (BInst.Info .Type == BaleInfo::WRPREDPREDREGION, " wrong argument" );
17431752 unsigned WrPredStart =
17441753 cast<ConstantInt>(BInst.Inst ->getOperand (2 ))->getZExtValue ();
17451754 Value *WrPredNewVal = getSplitOperand (
@@ -1869,15 +1878,15 @@ Value *GenXLegalization::splitInst(Value *PrevSliceRes, BaleInst BInst,
18691878 // predication logic anymore and can fallback to rdpredregions.
18701879 auto *SI = cast<ShuffleVectorInst>(BInst.Inst );
18711880 auto RS = ShuffleVectorAnalyzer::getReplicatedSliceDescriptor (SI);
1872- IGC_ASSERT (RS.SliceSize == Width && " Unexpected width for predicate shuffle split" );
1881+ IGC_ASSERT_MESSAGE (RS.SliceSize == Width, " Unexpected width for predicate shuffle split" );
18731882 Value *Pred = SI->getOperand (0 );
18741883 return Region::createRdPredRegionOrConst (
18751884 Pred, RS.InitialOffset , Width,
18761885 SI->getName () + " .split" + Twine (StartIdx), InsertBefore, DL);
18771886 }
18781887 }
18791888 // Splitting non-region instruction.
1880- IGC_ASSERT (!isa<PHINode>(BInst.Inst ) && " not expecting to split phi node" );
1889+ IGC_ASSERT_MESSAGE (!isa<PHINode>(BInst.Inst ), " not expecting to split phi node" );
18811890 if (CastInst *CI = dyn_cast<CastInst>(BInst.Inst )) {
18821891 Type *CastToTy = IGCLLVM::FixedVectorType::get (
18831892 cast<VectorType>(CI->getType ())->getElementType (), Width);
@@ -2028,7 +2037,8 @@ Value *GenXLegalization::getSplitOperand(Instruction *Inst, unsigned OperandNum,
20282037Instruction *
20292038GenXLegalization::convertToMultiIndirect (Instruction *Inst, Value *LastJoinVal,
20302039 Region *R, Instruction *InsertBefore) {
2031- IGC_ASSERT (!R->is2D () && (R->NumElements == 4 || R->NumElements == 8 ));
2040+ IGC_ASSERT (!R->is2D ());
2041+ IGC_ASSERT ((R->NumElements == 4 ) || (R->NumElements == 8 ));
20322042 Value *Indirect = R->Indirect ;
20332043 IGC_ASSERT (Indirect);
20342044 const DebugLoc &DL = Inst->getDebugLoc ();
@@ -2133,7 +2143,7 @@ Instruction *GenXLegalization::transformMoveType(Bale *B, IntegerType *FromTy,
21332143 using GenXIntrinsic::GenXRegion::NewValueOperandNum;
21342144 using GenXIntrinsic::GenXRegion::OldValueOperandNum;
21352145
2136- IGC_ASSERT (FromTy != ToTy && " Convertion of same types attempted" );
2146+ IGC_ASSERT_MESSAGE (FromTy != ToTy, " Convertion of same types attempted" );
21372147 // Recognize move dst and src in bale.
21382148 auto Head = B->getHead ();
21392149 auto HeadInst = Head->Inst ;
@@ -2376,8 +2386,8 @@ void GenXLegalization::fixIllegalPredicates(Function *F) {
23762386 if (GenXIntrinsic::getGenXIntrinsicID (Root->getOperand (0 )) ==
23772387 GenXIntrinsic::genx_wrpredregion)
23782388 continue ; // not root of tree
2379- IGC_ASSERT (isa<UndefValue>(Root->getOperand (0 )) &&
2380- " expecting undef input to root of tree" );
2389+ IGC_ASSERT_MESSAGE (isa<UndefValue>(Root->getOperand (0 )),
2390+ " expecting undef input to root of tree" );
23812391 // See if it really is illegally sized.
23822392 if (getPredPart (Root, 0 ).Size ==
23832393 cast<VectorType>(Root->getType ())->getNumElements ())
@@ -2423,8 +2433,8 @@ void GenXLegalization::fixIllegalPredicates(Function *F) {
24232433 unsigned WrSize = cast<VectorType>(Entry->Wr ->getOperand (1 )->getType ())
24242434 ->getNumElements ();
24252435 auto PP = getPredPart (Entry->Wr , WrOffset);
2426- IGC_ASSERT (WrOffset + WrSize <= PP.Offset + PP.Size &&
2427- " overlaps multiple parts" );
2436+ IGC_ASSERT_MESSAGE (WrOffset + WrSize <= PP.Offset + PP.Size ,
2437+ " overlaps multiple parts" );
24282438 Value *Part = Entry->Parts [PP.PartNum ];
24292439 if (WrSize != PP.Size ) {
24302440 // Not the whole part. We need to write into the previous value of this
@@ -2455,8 +2465,8 @@ void GenXLegalization::fixIllegalPredicates(Function *F) {
24552465 cast<ConstantInt>(Rd->getOperand (1 ))->getZExtValue ();
24562466 unsigned RdSize = cast<VectorType>(Rd->getType ())->getNumElements ();
24572467 auto PP = getPredPart (Entry->Wr , RdOffset);
2458- IGC_ASSERT (RdOffset + RdSize <= PP.Offset + PP.Size &&
2459- " overlaps multiple parts" );
2468+ IGC_ASSERT_MESSAGE (RdOffset + RdSize <= PP.Offset + PP.Size ,
2469+ " overlaps multiple parts" );
24602470 Value *Part = Entry->Parts [PP.PartNum ];
24612471 if (RdSize != PP.Size ) {
24622472 // Only reading a subregion of a part.
@@ -2468,20 +2478,24 @@ void GenXLegalization::fixIllegalPredicates(Function *F) {
24682478 // will arise where the input to legalization had an odd size
24692479 // rdpredregion in a wrregion where the input predicate is a v32i1
24702480 // from an odd size CM select using an i32 as the mask.
2471- # if _DEBUG
2481+
24722482 if (RdOffset) {
2473- unsigned RdMisalignment = 1U << findFirstSet (RdOffset);
2474- IGC_ASSERT ((RdMisalignment >= 8 ||
2483+ unsigned RdMisalignment = 0 ; // it will be assigned inside assertion statament
2484+ IGC_ASSERT ((RdMisalignment = 1U << findFirstSet (RdOffset), 1 ));
2485+ IGC_ASSERT_MESSAGE ((RdMisalignment >= 8 ||
24752486 (RdMisalignment == 4 && Rd->hasOneUse () &&
24762487 cast<Instruction>(Rd->use_begin ()->getUser ())
24772488 ->getOperand (1 )
24782489 ->getType ()
24792490 ->getScalarType ()
2480- ->getPrimitiveSizeInBits () == 64 )) &&
2481- !((RdOffset - PP.Offset ) % RdSize) &&
2491+ ->getPrimitiveSizeInBits () == 64 )),
2492+ " illegal rdpredregion" );
2493+ IGC_ASSERT (RdSize);
2494+ IGC_ASSERT_MESSAGE (!((RdOffset - PP.Offset ) % RdSize),
24822495 " illegal rdpredregion" );
2496+ (void ) RdMisalignment;
24832497 }
2484- # endif
2498+
24852499 // Create a new rdpredregion.
24862500 auto NewRd = Region::createRdPredRegion (
24872501 Part, RdOffset - PP.Offset , RdSize, " " , Rd, Rd->getDebugLoc ());
@@ -2496,9 +2510,10 @@ void GenXLegalization::fixIllegalPredicates(Function *F) {
24962510 for (auto ui = Entry->Wr ->use_begin (), ue = Entry->Wr ->use_end ();
24972511 ui != ue; ++ui) {
24982512 auto User = cast<Instruction>(ui->getUser ());
2499- IGC_ASSERT (GenXIntrinsic::getGenXIntrinsicID (User) ==
2500- GenXIntrinsic::genx_wrpredregion &&
2501- !ui->getOperandNo () && " expecting only wrpredregion uses" );
2513+ IGC_ASSERT_MESSAGE (GenXIntrinsic::getGenXIntrinsicID (User) == GenXIntrinsic::genx_wrpredregion,
2514+ " expecting only wrpredregion uses" );
2515+ IGC_ASSERT_MESSAGE (!ui->getOperandNo (),
2516+ " expecting only wrpredregion uses" );
25022517 Stack.push_back (StackEntry (User, Entry->Wr ));
25032518 }
25042519 }
0 commit comments