@@ -75,8 +75,8 @@ class AMDGPULibCalls {
75
75
bool sincosUseNative (CallInst *aCI, const FuncInfo &FInfo);
76
76
77
77
// evaluate calls if calls' arguments are constants.
78
- bool evaluateScalarMathFunc (const FuncInfo &FInfo, double & Res0,
79
- double & Res1, Constant *copr0, Constant *copr1 , Constant *copr2 );
78
+ bool evaluateScalarMathFunc (const FuncInfo &FInfo, double & Res0, double &Res1 ,
79
+ Constant *copr0 , Constant *copr1 );
80
80
bool evaluateCall (CallInst *aCI, const FuncInfo &FInfo);
81
81
82
82
// sqrt
@@ -1306,17 +1306,15 @@ bool AMDGPULibCalls::fold_sincos(FPMathOperator *FPOp, IRBuilder<> &B,
1306
1306
return true ;
1307
1307
}
1308
1308
1309
- bool AMDGPULibCalls::evaluateScalarMathFunc (const FuncInfo &FInfo,
1310
- double & Res0, double & Res1,
1311
- Constant *copr0, Constant *copr1,
1312
- Constant *copr2) {
1309
+ bool AMDGPULibCalls::evaluateScalarMathFunc (const FuncInfo &FInfo, double &Res0,
1310
+ double &Res1, Constant *copr0,
1311
+ Constant *copr1) {
1313
1312
// By default, opr0/opr1/opr3 holds values of float/double type.
1314
1313
// If they are not float/double, each function has to its
1315
1314
// operand separately.
1316
- double opr0= 0.0 , opr1= 0.0 , opr2= 0.0 ;
1315
+ double opr0 = 0.0 , opr1 = 0.0 ;
1317
1316
ConstantFP *fpopr0 = dyn_cast_or_null<ConstantFP>(copr0);
1318
1317
ConstantFP *fpopr1 = dyn_cast_or_null<ConstantFP>(copr1);
1319
- ConstantFP *fpopr2 = dyn_cast_or_null<ConstantFP>(copr2);
1320
1318
if (fpopr0) {
1321
1319
opr0 = (getArgType (FInfo) == AMDGPULibFunc::F64)
1322
1320
? fpopr0->getValueAPF ().convertToDouble ()
@@ -1329,12 +1327,6 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo,
1329
1327
: (double )fpopr1->getValueAPF ().convertToFloat ();
1330
1328
}
1331
1329
1332
- if (fpopr2) {
1333
- opr2 = (getArgType (FInfo) == AMDGPULibFunc::F64)
1334
- ? fpopr2->getValueAPF ().convertToDouble ()
1335
- : (double )fpopr2->getValueAPF ().convertToFloat ();
1336
- }
1337
-
1338
1330
switch (FInfo.getId ()) {
1339
1331
default : return false ;
1340
1332
@@ -1486,12 +1478,6 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo,
1486
1478
Res0 = sin (opr0);
1487
1479
Res1 = cos (opr0);
1488
1480
return true ;
1489
-
1490
- // three-arg functions
1491
- case AMDGPULibFunc::EI_FMA:
1492
- case AMDGPULibFunc::EI_MAD:
1493
- Res0 = opr0 * opr1 + opr2;
1494
- return true ;
1495
1481
}
1496
1482
1497
1483
return false ;
@@ -1504,7 +1490,6 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) {
1504
1490
1505
1491
Constant *copr0 = nullptr ;
1506
1492
Constant *copr1 = nullptr ;
1507
- Constant *copr2 = nullptr ;
1508
1493
if (numArgs > 0 ) {
1509
1494
if ((copr0 = dyn_cast<Constant>(aCI->getArgOperand (0 ))) == nullptr )
1510
1495
return false ;
@@ -1517,32 +1502,23 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) {
1517
1502
}
1518
1503
}
1519
1504
1520
- if (numArgs > 2 ) {
1521
- if ((copr2 = dyn_cast<Constant>(aCI->getArgOperand (2 ))) == nullptr )
1522
- return false ;
1523
- }
1524
-
1525
1505
// At this point, all arguments to aCI are constants.
1526
1506
1527
1507
// max vector size is 16, and sincos will generate two results.
1528
1508
double DVal0[16 ], DVal1[16 ];
1529
1509
int FuncVecSize = getVecSize (FInfo);
1530
1510
bool hasTwoResults = (FInfo.getId () == AMDGPULibFunc::EI_SINCOS);
1531
1511
if (FuncVecSize == 1 ) {
1532
- if (!evaluateScalarMathFunc (FInfo, DVal0[0 ],
1533
- DVal1[0 ], copr0, copr1, copr2)) {
1512
+ if (!evaluateScalarMathFunc (FInfo, DVal0[0 ], DVal1[0 ], copr0, copr1)) {
1534
1513
return false ;
1535
1514
}
1536
1515
} else {
1537
1516
ConstantDataVector *CDV0 = dyn_cast_or_null<ConstantDataVector>(copr0);
1538
1517
ConstantDataVector *CDV1 = dyn_cast_or_null<ConstantDataVector>(copr1);
1539
- ConstantDataVector *CDV2 = dyn_cast_or_null<ConstantDataVector>(copr2);
1540
1518
for (int i = 0 ; i < FuncVecSize; ++i) {
1541
1519
Constant *celt0 = CDV0 ? CDV0->getElementAsConstant (i) : nullptr ;
1542
1520
Constant *celt1 = CDV1 ? CDV1->getElementAsConstant (i) : nullptr ;
1543
- Constant *celt2 = CDV2 ? CDV2->getElementAsConstant (i) : nullptr ;
1544
- if (!evaluateScalarMathFunc (FInfo, DVal0[i],
1545
- DVal1[i], celt0, celt1, celt2)) {
1521
+ if (!evaluateScalarMathFunc (FInfo, DVal0[i], DVal1[i], celt0, celt1)) {
1546
1522
return false ;
1547
1523
}
1548
1524
}
0 commit comments