Skip to content

Commit 2b497fe

Browse files
mmereckiigcbot
authored andcommitted
Update pattern match for packed <4 x i8>
This PR extends the existing implemetnation to also handle `bitcast` instructions from `float` to `<4 x i8>`.
1 parent e20fddf commit 2b497fe

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,8 @@ namespace IGC
32473247
isa<ConstantInt>(extract->getIndexOperand()) &&
32483248
isa<BitCastInst>(extract->getVectorOperand()) &&
32493249
cast<BitCastInst>(extract->getVectorOperand())->getType()->isIntOrIntVectorTy(8) &&
3250-
cast<BitCastInst>(extract->getVectorOperand())->getOperand(0)->getType()->isIntegerTy(32))
3250+
!cast<BitCastInst>(extract->getVectorOperand())->getOperand(0)->getType()->isVectorTy() &&
3251+
cast<BitCastInst>(extract->getVectorOperand())->getOperand(0)->getType()->getPrimitiveSizeInBits() == 32)
32513252
{
32523253
UnpackPattern* pattern = new (m_allocator) UnpackPattern();
32533254
auto bitcast = cast<BitCastInst>(extract->getVectorOperand());
@@ -3284,7 +3285,8 @@ namespace IGC
32843285
}
32853286
};
32863287

3287-
if (I.getType()->isIntegerTy(32) &&
3288+
if (!I.getType()->isVectorTy() &&
3289+
I.getType()->getPrimitiveSizeInBits() == 32 &&
32883290
I.getOperand(0)->getType()->isIntOrIntVectorTy(8) &&
32893291
isa<InsertElementInst>(I.getOperand(0)))
32903292
{
@@ -3388,7 +3390,8 @@ namespace IGC
33883390
}
33893391
};
33903392

3391-
if (I.getType()->isIntegerTy(32) &&
3393+
if (!I.getType()->isVectorTy() &&
3394+
I.getType()->getPrimitiveSizeInBits() == 32 &&
33923395
I.getOperand(0)->getType()->isIntOrIntVectorTy(8) &&
33933396
isa<InsertElementInst>(I.getOperand(0)))
33943397
{
@@ -3422,7 +3425,8 @@ namespace IGC
34223425
if (!ee ||
34233426
!isa<ConstantInt>(ee->getOperand(1)) ||
34243427
!isa<BitCastInst>(ee->getOperand(0)) ||
3425-
!(cast<BitCastInst>(ee->getOperand(0)))->getOperand(0)->getType()->isIntegerTy(32))
3428+
(cast<BitCastInst>(ee->getOperand(0)))->getOperand(0)->getType()->isVectorTy() ||
3429+
((cast<BitCastInst>(ee->getOperand(0)))->getOperand(0)->getType()->getPrimitiveSizeInBits() != 32))
34263430
{
34273431
return false;
34283432
}
@@ -3433,7 +3437,9 @@ namespace IGC
34333437
else
34343438
{
34353439
if (!isa<UndefValue>(baseVec) &&
3436-
(!isa<BitCastInst>(baseVec) || !(cast<BitCastInst>(baseVec))->getOperand(0)->getType()->isIntegerTy(32)))
3440+
(!isa<BitCastInst>(baseVec) ||
3441+
(cast<BitCastInst>(baseVec))->getOperand(0)->getType()->isVectorTy() ||
3442+
(cast<BitCastInst>(baseVec))->getOperand(0)->getType()->getPrimitiveSizeInBits() != 32))
34373443
{
34383444
return false;
34393445
}
@@ -3535,7 +3541,8 @@ namespace IGC
35353541
if (isa<ConstantInt>(extract->getIndexOperand()) &&
35363542
isa<BitCastInst>(extract->getVectorOperand()) &&
35373543
cast<BitCastInst>(extract->getVectorOperand())->getType()->isIntOrIntVectorTy(8) &&
3538-
cast<BitCastInst>(extract->getVectorOperand())->getOperand(0)->getType()->isIntegerTy(32))
3544+
!cast<BitCastInst>(extract->getVectorOperand())->getOperand(0)->getType()->isVectorTy() &&
3545+
cast<BitCastInst>(extract->getVectorOperand())->getOperand(0)->getType()->getPrimitiveSizeInBits() == 32)
35393546
{
35403547
sources[i] = std::make_tuple(
35413548
true,

0 commit comments

Comments
 (0)