@@ -275,8 +275,7 @@ bool genx::loadConstantsForInlineAsm(
275
275
* loadPhiConstants.
276
276
*/
277
277
bool genx::loadConstants (Instruction *Inst, const GenXSubtarget &Subtarget,
278
- const DataLayout &DL,
279
- SmallVectorImpl<Instruction *> *AddedInstructions) {
278
+ const DataLayout &DL) {
280
279
bool Modified = false ;
281
280
Use *U;
282
281
if (isa<PHINode>(Inst))
@@ -298,9 +297,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
298
297
return C1 && C1->isAllOnesValue ();
299
298
};
300
299
if (!IsNot ()) {
301
- Inst->setOperand (
302
- oi, ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
303
- .load (Inst));
300
+ Inst->setOperand (oi, ConstantLoader (C, Subtarget, DL).load (Inst));
304
301
Modified = true ;
305
302
}
306
303
}
@@ -309,8 +306,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
309
306
// select: disallow constant selector
310
307
U = &Inst->getOperandUse (0 );
311
308
if (auto C = dyn_cast<Constant>(*U)) {
312
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
313
- .load (Inst);
309
+ *U = ConstantLoader (C, Subtarget, DL).load (Inst);
314
310
Modified = true ;
315
311
}
316
312
return Modified;
@@ -320,8 +316,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
320
316
// on element operand.
321
317
U = &Inst->getOperandUse (1 );
322
318
if (auto C = dyn_cast<Constant>(*U)) {
323
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
324
- .load (Inst);
319
+ *U = ConstantLoader (C, Subtarget, DL).load (Inst);
325
320
Modified = true ;
326
321
}
327
322
// Also disallow constant (other than undef) on old struct value operand.
@@ -336,9 +331,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
336
331
// Conditional branch: disallow constant condition.
337
332
if (Br->isConditional ()) {
338
333
if (auto C = dyn_cast<Constant>(Br->getCondition ())) {
339
- Br->setCondition (
340
- ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
341
- .load (Br));
334
+ Br->setCondition (ConstantLoader (C, Subtarget, DL).load (Br));
342
335
Modified = true ;
343
336
}
344
337
}
@@ -351,9 +344,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
351
344
Ret->getFunction ()->getLinkage () == GlobalValue::InternalLinkage) {
352
345
if (auto C = dyn_cast<Constant>(Ret->getOperand (0 ))) {
353
346
if (!C->getType ()->isVoidTy () && !isa<UndefValue>(C)) {
354
- Ret->setOperand (
355
- 0 , ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
356
- .load (Ret));
347
+ Ret->setOperand (0 , ConstantLoader (C, Subtarget, DL).load (Ret));
357
348
Modified = true ;
358
349
}
359
350
}
@@ -364,7 +355,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
364
355
if (!CI)
365
356
return Modified;
366
357
if (CI->isInlineAsm ())
367
- return loadConstantsForInlineAsm (CI, Subtarget, DL, AddedInstructions );
358
+ return loadConstantsForInlineAsm (CI, Subtarget, DL, nullptr );
368
359
int IntrinsicID = vc::getAnyIntrinsicID (CI);
369
360
switch (IntrinsicID) {
370
361
case GenXIntrinsic::not_any_intrinsic:
@@ -380,8 +371,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
380
371
U = &CI->getOperandUse (i);
381
372
if (auto C = dyn_cast<Constant>(*U)) {
382
373
if (!isa<UndefValue>(C)) {
383
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
384
- .loadBig (CI);
374
+ *U = ConstantLoader (C, Subtarget, DL).loadBig (CI);
385
375
Modified = true ;
386
376
}
387
377
}
@@ -395,8 +385,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
395
385
// abs modifier: disallow constant input.
396
386
U = &CI->getOperandUse (0 );
397
387
if (auto C = dyn_cast<Constant>(*U)) {
398
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
399
- .load (CI);
388
+ *U = ConstantLoader (C, Subtarget, DL).load (CI);
400
389
Modified = true ;
401
390
}
402
391
break ;
@@ -406,8 +395,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
406
395
// rdpredregion, any, all: disallow constant input
407
396
U = &CI->getOperandUse (0 );
408
397
if (auto C = dyn_cast<Constant>(*U)) {
409
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
410
- .load (CI);
398
+ *U = ConstantLoader (C, Subtarget, DL).load (CI);
411
399
Modified = true ;
412
400
}
413
401
break ;
@@ -416,16 +404,14 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
416
404
// rdregion: disallow constant input
417
405
U = &CI->getOperandUse (0 );
418
406
if (auto C = dyn_cast<Constant>(*U)) {
419
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
420
- .loadBig (CI);
407
+ *U = ConstantLoader (C, Subtarget, DL).loadBig (CI);
421
408
Modified = true ;
422
409
}
423
410
// Also disallow constant vector index (constant scalar OK).
424
411
U = &CI->getOperandUse (GenXIntrinsic::GenXRegion::RdIndexOperandNum);
425
412
if (auto C = dyn_cast<Constant>(*U)) {
426
413
if (isa<VectorType>(C->getType ())) {
427
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
428
- .load (CI);
414
+ *U = ConstantLoader (C, Subtarget, DL).load (CI);
429
415
Modified = true ;
430
416
}
431
417
}
@@ -436,8 +422,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
436
422
U = &CI->getOperandUse (0 );
437
423
if (auto C = dyn_cast<Constant>(*U)) {
438
424
if (!isa<UndefValue>(C)) {
439
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
440
- .loadBig (CI);
425
+ *U = ConstantLoader (C, Subtarget, DL).loadBig (CI);
441
426
Modified = true ;
442
427
}
443
428
}
@@ -448,26 +433,23 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
448
433
U = &CI->getOperandUse (0 );
449
434
if (auto C = dyn_cast<Constant>(*U)) {
450
435
if (!isa<UndefValue>(C)) {
451
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
452
- .loadBig (CI);
436
+ *U = ConstantLoader (C, Subtarget, DL).loadBig (CI);
453
437
Modified = true ;
454
438
}
455
439
}
456
440
// Also disallow constant vector index (constant scalar OK).
457
441
U = &CI->getOperandUse (GenXIntrinsic::GenXRegion::WrIndexOperandNum);
458
442
if (auto C = dyn_cast<Constant>(*U)) {
459
443
if (isa<VectorType>(C->getType ())) {
460
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
461
- .load (CI);
444
+ *U = ConstantLoader (C, Subtarget, DL).load (CI);
462
445
Modified = true ;
463
446
}
464
447
}
465
448
// Also disallow constant predicate unless all ones.
466
449
U = &CI->getOperandUse (GenXIntrinsic::GenXRegion::PredicateOperandNum);
467
450
if (auto C = dyn_cast<Constant>(*U)) {
468
451
if (!C->isAllOnesValue ()) {
469
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
470
- .load (CI);
452
+ *U = ConstantLoader (C, Subtarget, DL).load (CI);
471
453
Modified = true ;
472
454
}
473
455
}
@@ -480,8 +462,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
480
462
U = &CI->getOperandUse (2 );
481
463
if (auto C = dyn_cast<Constant>(*U)) {
482
464
if (!C->isNullValue ()) {
483
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
484
- .load (CI);
465
+ *U = ConstantLoader (C, Subtarget, DL).load (CI);
485
466
Modified = true ;
486
467
}
487
468
}
@@ -533,8 +514,7 @@ bool genx::loadConstants(Instruction *Inst, const GenXSubtarget &Subtarget,
533
514
continue ;
534
515
}
535
516
// Operand is not allowed to be constant. Insert code to load it.
536
- *U = ConstantLoader (C, Subtarget, DL, nullptr , AddedInstructions)
537
- .loadBig (CI);
517
+ *U = ConstantLoader (C, Subtarget, DL).loadBig (CI);
538
518
Modified = true ;
539
519
}
540
520
break ;
@@ -1305,7 +1285,7 @@ Instruction *ConstantLoader::loadSplatConstant(Instruction *InsertPos) {
1305
1285
// Create <1 x T> constant and broadcast it through rdregion.
1306
1286
Constant *CV = ConstantVector::get (C1);
1307
1287
// Load that scalar constant first.
1308
- ConstantLoader L (CV, Subtarget, DL, nullptr , AddedInstructions );
1288
+ ConstantLoader L (CV, Subtarget, DL);
1309
1289
Value *V = L.load (InsertPos);
1310
1290
// Broadcast through rdregion.
1311
1291
Instruction *Result = nullptr ;
@@ -1415,7 +1395,7 @@ Instruction *ConstantLoader::loadNonPackedIntConst(Instruction *InsertBefore) {
1415
1395
std::min (PowerOf2Floor (NumElements - Idx), (uint64_t )ImmIntVec::Width);
1416
1396
Constant *SubC = getConstantSubvector (C, Idx, Size);
1417
1397
Value *SubV = SubC;
1418
- ConstantLoader SubLoader (SubC, Subtarget, DL, nullptr , AddedInstructions );
1398
+ ConstantLoader SubLoader (SubC, Subtarget, DL);
1419
1399
SubV = SubLoader.load (InsertBefore);
1420
1400
1421
1401
Region R (C, &DL);
@@ -1461,8 +1441,7 @@ Instruction *ConstantLoader::loadPackedInt(Instruction *Inst) {
1461
1441
cast<ConstantInt>(PackedVals.back ())->getSExtValue () <= 15 );
1462
1442
}
1463
1443
1464
- ConstantLoader Packed (ConstantVector::get (PackedVals), Subtarget, DL, nullptr ,
1465
- AddedInstructions);
1444
+ ConstantLoader Packed (ConstantVector::get (PackedVals), Subtarget, DL);
1466
1445
auto *LoadPacked = Packed.loadNonPackedIntConst (Inst);
1467
1446
if (PackedIntScale != 1 ) {
1468
1447
auto *SplatVal =
@@ -1667,7 +1646,7 @@ Instruction *ConstantLoader::loadBig(Instruction *InsertBefore) {
1667
1646
// value with wrregion.
1668
1647
Constant *SubC = getConstantSubvector (C, Idx, Size);
1669
1648
Value *SubV = SubC;
1670
- ConstantLoader SubLoader (SubC, Subtarget, DL, nullptr , AddedInstructions );
1649
+ ConstantLoader SubLoader (SubC, Subtarget, DL);
1671
1650
if (!SubLoader.isSimple ())
1672
1651
SubV = SubLoader.loadNonSimple (InsertBefore);
1673
1652
Region R (C, &DL);
0 commit comments