@@ -317,17 +317,12 @@ void GenXVisaRegAlloc::extraCoalescing()
317317/* **********************************************************************
318318 * allocReg : allocate a register for a LiveRange
319319 */
320- void GenXVisaRegAlloc::allocReg (LiveRange *LR)
321- {
320+ void GenXVisaRegAlloc::allocReg (LiveRange *LR) {
322321 if (LR->value_empty ())
323322 return ;
324323 if (LR->getCategory () >= RegCategory::NUMREALCATEGORIES)
325324 return ; // don't allocate register to EM or RM value
326- LLVM_DEBUG (
327- dbgs () << " Allocating " ;
328- LR->print (dbgs ());
329- dbgs () << " \n "
330- );
325+ LLVM_DEBUG (dbgs () << " Allocating " ; LR->print (dbgs ()); dbgs () << " \n " );
331326 SimpleValue V = *LR->value_begin ();
332327 Type *Ty = V.getType ();
333328 if (auto GV = dyn_cast<GlobalVariable>(V.getValue ()))
@@ -336,28 +331,29 @@ void GenXVisaRegAlloc::allocReg(LiveRange *LR)
336331 assert (!Ty->isVoidTy ());
337332 if (LR->Category == RegCategory::PREDICATE) {
338333 VectorType *VT = dyn_cast<VectorType>(Ty);
339- assert ((!VT || genx::exactLog2 (VT->getNumElements ()) >= 0 ) && " invalid predicate width" );
334+ assert ((!VT || genx::exactLog2 (VT->getNumElements ()) >= 0 ) &&
335+ " invalid predicate width" );
340336 (void )VT;
341337 }
342338 // Allocate the register, also setting the alignment.
339+ Reg *NewReg =
340+ createReg (LR->Category , Ty, DONTCARESIGNED, LR->getLogAlignment ());
343341 // Assign to the values. If any value is an input arg, ensure the register
344342 // gets its type, to avoid needing an alias for an input arg.
345- for (auto &F : LR->Funcs ) {
346- Reg *NewReg =
347- createReg (LR->Category , Ty, DONTCARESIGNED, LR->getLogAlignment ());
348- if (RegMap.count (F) > 0 ) {
349- for (LiveRange::value_iterator vi = LR->value_begin (),
350- ve = LR->value_end ();
351- vi != ve; ++vi) {
352- LLVM_DEBUG (dbgs () << " Allocating reg " << NewReg->Num << " to "
343+ for (LiveRange::value_iterator vi = LR->value_begin (), ve = LR->value_end ();
344+ vi != ve; ++vi) {
345+ for (auto &F : LR->Funcs ) {
346+ if (FGA->getGroup (F) == FG) {
347+ assert (RegMap.count (F) > 0 );
348+ LLVM_DEBUG (dbgs () << " Allocating reg " << NewReg->Num << " for "
353349 << *(vi->getValue ()) << " in func " << F->getName ()
354- << " \n " ; );
350+ << " \n " );
355351 assert (RegMap.at (F).find (*vi) == RegMap.at (F).end ());
356352 RegMap.at (F)[*vi] = NewReg;
357- if (isa<Argument>(vi->getValue ()))
358- NewReg->Ty = vi->getType ();
359353 }
360354 }
355+ if (isa<Argument>(vi->getValue ()))
356+ NewReg->Ty = vi->getType ();
361357 }
362358}
363359
0 commit comments