@@ -3311,11 +3311,17 @@ bool GenXPatternMatch::distributeIntegerMul(Function *F) {
3311
3311
// where ShtAmt[0] is a constant vector and ShtAmt[i] are constant splats.
3312
3312
static bool analyzeForShiftPattern (Constant *C,
3313
3313
SmallVectorImpl<Constant *> &ShtAmt,
3314
- const DataLayout &DL) {
3315
- unsigned Width = 8 ;
3314
+ const DataLayout &DL,
3315
+ const llvm::GenXSubtarget &Subtarget) {
3316
3316
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(C->getType ());
3317
- if (!VT || VT->getNumElements () <= Width || VT-> getScalarSizeInBits () == 1 )
3317
+ if (!VT || VT->getScalarSizeInBits () == 1 )
3318
3318
return false ;
3319
+
3320
+ unsigned ElmSz = VT->getScalarSizeInBits () / genx::ByteBits;
3321
+ unsigned Width = Subtarget.getGRFByteSize () / ElmSz;
3322
+ if (cast<IGCLLVM::FixedVectorType>(VT)->getNumElements () <= Width)
3323
+ return false ;
3324
+
3319
3325
unsigned NElts = VT->getNumElements ();
3320
3326
if (NElts % Width != 0 )
3321
3327
return false ;
@@ -3388,6 +3394,9 @@ static bool analyzeForShiftPattern(Constant *C,
3388
3394
}
3389
3395
3390
3396
bool GenXPatternMatch::vectorizeConstants (Function *F) {
3397
+ const GenXSubtarget *ST = &getAnalysis<TargetPassConfig>()
3398
+ .getTM <GenXTargetMachine>()
3399
+ .getGenXSubtarget ();
3391
3400
bool Changed = false ;
3392
3401
for (auto &BB : F->getBasicBlockList ()) {
3393
3402
for (auto I = BB.begin (); I != BB.end ();) {
@@ -3410,7 +3419,7 @@ bool GenXPatternMatch::vectorizeConstants(Function *F) {
3410
3419
C->getSplatValue ())
3411
3420
continue ;
3412
3421
SmallVector<Constant *, 8 > ShtAmt;
3413
- if (analyzeForShiftPattern (C, ShtAmt, *DL)) {
3422
+ if (analyzeForShiftPattern (C, ShtAmt, *DL, *ST )) {
3414
3423
// W1 = wrrregion(undef, ShtAmt[0], 0);
3415
3424
// V2 = fadd ShtAmt[0], ShtAmt[1]
3416
3425
// W2 = wrregion(W1, V2, Width)
0 commit comments