@@ -4619,19 +4619,29 @@ namespace IGC
4619
4619
pattern->sources [1 ] = GetSource (s1, false , false , IsSourceOfSample (&I));
4620
4620
pattern->sources [2 ] = GetSource (s2, false , false , IsSourceOfSample (&I));
4621
4621
4622
- // BFN can use imm16 in src0 and src2, check for those;
4622
+ // BFN can use imm16 in src0 and src2 (not src1).
4623
+ // Directly pass such immediates (or when lossless conversion is possible);
4623
4624
// otherwise try to add to constant pool even int32.
4624
- if (dyn_cast<ConstantInt>(s0) && !s0-> getType ()-> isIntegerTy ( 16 ) )
4625
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(s0))
4625
4626
{
4626
- AddToConstantPool (I.getParent (), s0); pattern->sources [0 ].fromConstantPool = true ;
4627
+ if (!s0->getType ()->isIntegerTy (16 ) && !CI->getValue ().isIntN (16 ))
4628
+ {
4629
+ AddToConstantPool (I.getParent (), s0);
4630
+ pattern->sources [0 ].fromConstantPool = true ;
4631
+ }
4627
4632
}
4628
4633
if (dyn_cast<ConstantInt>(s1))
4629
4634
{
4630
- AddToConstantPool (I.getParent (), s1); pattern->sources [1 ].fromConstantPool = true ;
4635
+ AddToConstantPool (I.getParent (), s1);
4636
+ pattern->sources [1 ].fromConstantPool = true ;
4631
4637
}
4632
- if (dyn_cast<ConstantInt>(s2) && !s2-> getType ()-> isIntegerTy ( 16 ))
4638
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(s2))
4633
4639
{
4634
- AddToConstantPool (I.getParent (), s2); pattern->sources [2 ].fromConstantPool = true ;
4640
+ if (!s2->getType ()->isIntegerTy (16 ) && !CI->getValue ().isIntN (16 ))
4641
+ {
4642
+ AddToConstantPool (I.getParent (), s2);
4643
+ pattern->sources [2 ].fromConstantPool = true ;
4644
+ }
4635
4645
}
4636
4646
4637
4647
AddPattern (pattern);
0 commit comments