@@ -2760,18 +2760,14 @@ namespace IGC
27602760 pattern->sources [1 ] = GetSource (I.getOperand (1 ), supportModifer, supportRegioning);
27612761 }
27622762
2763- if (nbSources > 1 && (I. getType ()-> isDoubleTy () || I. getType ()-> isIntegerTy ( 64 )) )
2763+ if (nbSources > 1 )
27642764 {
27652765 // add df imm to constant pool for binary/ternary inst
2766- // we do 64-bit int imm biggerthan 32 bits, since smaller may fit in D/W
2766+ // we do 64-bit int imm bigger than 32 bits, since smaller may fit in D/W
27672767 for (int i = 0 , numSrc = (int )nbSources; i < numSrc; ++i)
27682768 {
27692769 Value* op = I.getOperand (i);
2770- bool isDF = isa<ConstantFP>(op);
2771- auto ci = dyn_cast<ConstantInt>(op);
2772- bool isBigQW = ci && !ci->getValue ().isNullValue () && !ci->getValue ().isSignedIntN (32 );
2773-
2774- if (isDF || isBigQW)
2770+ if (isCandidateForConstantPool (op))
27752771 {
27762772 AddToConstantPool (I.getParent (), op);
27772773 pattern->sources [i].fromConstantPool = true ;
@@ -2978,6 +2974,20 @@ namespace IGC
29782974 pattern->sources [0 ] = GetSource (I.getCondition (), false , false );
29792975 pattern->sources [1 ] = GetSource (I.getTrueValue (), true , false );
29802976 pattern->sources [2 ] = GetSource (I.getFalseValue (), true , false );
2977+
2978+ // try to add to constant pool whatever possible.
2979+ if (isCandidateForConstantPool (I.getTrueValue ()))
2980+ {
2981+ AddToConstantPool (I.getParent (), I.getTrueValue ());
2982+ pattern->sources [1 ].fromConstantPool = true ;
2983+ }
2984+
2985+ if (isCandidateForConstantPool (I.getFalseValue ()))
2986+ {
2987+ AddToConstantPool (I.getParent (), I.getFalseValue ());
2988+ pattern->sources [2 ].fromConstantPool = true ;
2989+ }
2990+
29812991 AddPattern (pattern);
29822992 return true ;
29832993 }
@@ -3425,16 +3435,10 @@ namespace IGC
34253435 }
34263436 pattern->sources [i] = GetSource (src, mod, false );
34273437
3428- if (src-> getType ()-> isIntegerTy ( 64 ))
3438+ if (isCandidateForConstantPool (src ))
34293439 {
3430- auto ci = dyn_cast<ConstantInt>(src);
3431- bool isBigQW = ci && !ci->getValue ().isNullValue () && !ci->getValue ().isSignedIntN (32 );
3432-
3433- if (isBigQW)
3434- {
3435- AddToConstantPool (I.getParent (), src);
3436- pattern->sources [i].fromConstantPool = true ;
3437- }
3440+ AddToConstantPool (I.getParent (), src);
3441+ pattern->sources [i].fromConstantPool = true ;
34383442 }
34393443
34403444
@@ -4226,6 +4230,14 @@ namespace IGC
42264230 return found;
42274231 }
42284232
4233+ bool isCandidateForConstantPool (llvm::Value * val)
4234+ {
4235+ auto ci = dyn_cast<ConstantInt>(val);
4236+ bool isBigQW = ci && !ci->getValue ().isNullValue () && !ci->getValue ().isSignedIntN (32 );
4237+ bool isDF = val->getType ()->isDoubleTy ();
4238+ return (isBigQW || isDF);
4239+ };
4240+
42294241 uint CodeGenPatternMatch::GetBlockId (llvm::BasicBlock* block)
42304242 {
42314243 auto it = m_blockMap.find (block);
0 commit comments