@@ -2760,18 +2760,14 @@ namespace IGC
2760
2760
pattern->sources [1 ] = GetSource (I.getOperand (1 ), supportModifer, supportRegioning);
2761
2761
}
2762
2762
2763
- if (nbSources > 1 && (I. getType ()-> isDoubleTy () || I. getType ()-> isIntegerTy ( 64 )) )
2763
+ if (nbSources > 1 )
2764
2764
{
2765
2765
// 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
2767
2767
for (int i = 0 , numSrc = (int )nbSources; i < numSrc; ++i)
2768
2768
{
2769
2769
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))
2775
2771
{
2776
2772
AddToConstantPool (I.getParent (), op);
2777
2773
pattern->sources [i].fromConstantPool = true ;
@@ -2978,6 +2974,20 @@ namespace IGC
2978
2974
pattern->sources [0 ] = GetSource (I.getCondition (), false , false );
2979
2975
pattern->sources [1 ] = GetSource (I.getTrueValue (), true , false );
2980
2976
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
+
2981
2991
AddPattern (pattern);
2982
2992
return true ;
2983
2993
}
@@ -3425,16 +3435,10 @@ namespace IGC
3425
3435
}
3426
3436
pattern->sources [i] = GetSource (src, mod, false );
3427
3437
3428
- if (src-> getType ()-> isIntegerTy ( 64 ))
3438
+ if (isCandidateForConstantPool (src ))
3429
3439
{
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 ;
3438
3442
}
3439
3443
3440
3444
@@ -4226,6 +4230,14 @@ namespace IGC
4226
4230
return found;
4227
4231
}
4228
4232
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
+
4229
4241
uint CodeGenPatternMatch::GetBlockId (llvm::BasicBlock* block)
4230
4242
{
4231
4243
auto it = m_blockMap.find (block);
0 commit comments