@@ -6161,7 +6161,8 @@ static Value *simplifyLdexp(Value *Op0, Value *Op1, const SimplifyQuery &Q,
6161
6161
}
6162
6162
6163
6163
static Value *simplifyUnaryIntrinsic (Function *F, Value *Op0,
6164
- const SimplifyQuery &Q) {
6164
+ const SimplifyQuery &Q,
6165
+ const CallBase *Call) {
6165
6166
// Idempotent functions return the same result when called repeatedly.
6166
6167
Intrinsic::ID IID = F->getIntrinsicID ();
6167
6168
if (isIdempotent (IID))
@@ -6212,31 +6213,31 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
6212
6213
}
6213
6214
case Intrinsic::exp:
6214
6215
// exp(log(x)) -> x
6215
- if (Q. CxtI ->hasAllowReassoc () &&
6216
+ if (Call ->hasAllowReassoc () &&
6216
6217
match (Op0, m_Intrinsic<Intrinsic::log>(m_Value (X))))
6217
6218
return X;
6218
6219
break ;
6219
6220
case Intrinsic::exp2:
6220
6221
// exp2(log2(x)) -> x
6221
- if (Q. CxtI ->hasAllowReassoc () &&
6222
+ if (Call ->hasAllowReassoc () &&
6222
6223
match (Op0, m_Intrinsic<Intrinsic::log2>(m_Value (X))))
6223
6224
return X;
6224
6225
break ;
6225
6226
case Intrinsic::exp10:
6226
6227
// exp10(log10(x)) -> x
6227
- if (Q. CxtI ->hasAllowReassoc () &&
6228
+ if (Call ->hasAllowReassoc () &&
6228
6229
match (Op0, m_Intrinsic<Intrinsic::log10>(m_Value (X))))
6229
6230
return X;
6230
6231
break ;
6231
6232
case Intrinsic::log:
6232
6233
// log(exp(x)) -> x
6233
- if (Q. CxtI ->hasAllowReassoc () &&
6234
+ if (Call ->hasAllowReassoc () &&
6234
6235
match (Op0, m_Intrinsic<Intrinsic::exp>(m_Value (X))))
6235
6236
return X;
6236
6237
break ;
6237
6238
case Intrinsic::log2:
6238
6239
// log2(exp2(x)) -> x
6239
- if (Q. CxtI ->hasAllowReassoc () &&
6240
+ if (Call ->hasAllowReassoc () &&
6240
6241
(match (Op0, m_Intrinsic<Intrinsic::exp2>(m_Value (X))) ||
6241
6242
match (Op0,
6242
6243
m_Intrinsic<Intrinsic::pow>(m_SpecificFP (2.0 ), m_Value (X)))))
@@ -6245,7 +6246,7 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
6245
6246
case Intrinsic::log10:
6246
6247
// log10(pow(10.0, x)) -> x
6247
6248
// log10(exp10(x)) -> x
6248
- if (Q. CxtI ->hasAllowReassoc () &&
6249
+ if (Call ->hasAllowReassoc () &&
6249
6250
(match (Op0, m_Intrinsic<Intrinsic::exp10>(m_Value (X))) ||
6250
6251
match (Op0,
6251
6252
m_Intrinsic<Intrinsic::pow>(m_SpecificFP (10.0 ), m_Value (X)))))
@@ -6346,7 +6347,8 @@ static Value *foldMinimumMaximumSharedOp(Intrinsic::ID IID, Value *Op0,
6346
6347
}
6347
6348
6348
6349
static Value *simplifyBinaryIntrinsic (Function *F, Value *Op0, Value *Op1,
6349
- const SimplifyQuery &Q) {
6350
+ const SimplifyQuery &Q,
6351
+ const CallBase *Call) {
6350
6352
Intrinsic::ID IID = F->getIntrinsicID ();
6351
6353
Type *ReturnType = F->getReturnType ();
6352
6354
unsigned BitWidth = ReturnType->getScalarSizeInBits ();
@@ -6606,20 +6608,19 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1,
6606
6608
// float, if the ninf flag is set.
6607
6609
const APFloat *C;
6608
6610
if (match (Op1, m_APFloat (C)) &&
6609
- (C->isInfinity () || (isa<FPMathOperator>(Q.CxtI ) &&
6610
- Q.CxtI ->hasNoInfs () && C->isLargest ()))) {
6611
+ (C->isInfinity () || (Call->hasNoInfs () && C->isLargest ()))) {
6611
6612
// minnum(X, -inf) -> -inf
6612
6613
// maxnum(X, +inf) -> +inf
6613
6614
// minimum(X, -inf) -> -inf if nnan
6614
6615
// maximum(X, +inf) -> +inf if nnan
6615
- if (C->isNegative () == IsMin && (!PropagateNaN || Q. CxtI ->hasNoNaNs ()))
6616
+ if (C->isNegative () == IsMin && (!PropagateNaN || Call ->hasNoNaNs ()))
6616
6617
return ConstantFP::get (ReturnType, *C);
6617
6618
6618
6619
// minnum(X, +inf) -> X if nnan
6619
6620
// maxnum(X, -inf) -> X if nnan
6620
6621
// minimum(X, +inf) -> X
6621
6622
// maximum(X, -inf) -> X
6622
- if (C->isNegative () != IsMin && (PropagateNaN || Q. CxtI ->hasNoNaNs ()))
6623
+ if (C->isNegative () != IsMin && (PropagateNaN || Call ->hasNoNaNs ()))
6623
6624
return Op0;
6624
6625
}
6625
6626
@@ -6678,10 +6679,10 @@ static Value *simplifyIntrinsic(CallBase *Call, Value *Callee,
6678
6679
}
6679
6680
6680
6681
if (NumOperands == 1 )
6681
- return simplifyUnaryIntrinsic (F, Args[0 ], Q);
6682
+ return simplifyUnaryIntrinsic (F, Args[0 ], Q, Call );
6682
6683
6683
6684
if (NumOperands == 2 )
6684
- return simplifyBinaryIntrinsic (F, Args[0 ], Args[1 ], Q);
6685
+ return simplifyBinaryIntrinsic (F, Args[0 ], Args[1 ], Q, Call );
6685
6686
6686
6687
// Handle intrinsics with 3 or more arguments.
6687
6688
switch (IID) {
0 commit comments