@@ -327,7 +327,7 @@ class AMDGPUCodeGenPrepareImpl
327
327
328
328
bool visitIntrinsicInst (IntrinsicInst &I);
329
329
bool visitBitreverseIntrinsicInst (IntrinsicInst &I);
330
- bool visitMinNum (IntrinsicInst &I);
330
+ bool visitFMinLike (IntrinsicInst &I);
331
331
bool visitSqrt (IntrinsicInst &I);
332
332
bool run ();
333
333
};
@@ -2197,7 +2197,9 @@ bool AMDGPUCodeGenPrepareImpl::visitIntrinsicInst(IntrinsicInst &I) {
2197
2197
case Intrinsic::bitreverse:
2198
2198
return visitBitreverseIntrinsicInst (I);
2199
2199
case Intrinsic::minnum:
2200
- return visitMinNum (I);
2200
+ case Intrinsic::minimumnum:
2201
+ case Intrinsic::minimum:
2202
+ return visitFMinLike (I);
2201
2203
case Intrinsic::sqrt:
2202
2204
return visitSqrt (I);
2203
2205
default :
@@ -2216,15 +2218,22 @@ bool AMDGPUCodeGenPrepareImpl::visitBitreverseIntrinsicInst(IntrinsicInst &I) {
2216
2218
}
2217
2219
2218
2220
// / Match non-nan fract pattern.
2219
- // / minnum(fsub(x, floor(x)), nextafter(1.0, -1.0)
2221
+ // / minnum(fsub(x, floor(x)), nextafter(1.0, -1.0))
2222
+ // / minimumnum(fsub(x, floor(x)), nextafter(1.0, -1.0))
2223
+ // / minimum(fsub(x, floor(x)), nextafter(1.0, -1.0))
2220
2224
// /
2221
2225
// / If fract is a useful instruction for the subtarget. Does not account for the
2222
2226
// / nan handling; the instruction has a nan check on the input value.
2223
2227
Value *AMDGPUCodeGenPrepareImpl::matchFractPat (IntrinsicInst &I) {
2224
2228
if (ST.hasFractBug ())
2225
2229
return nullptr ;
2226
2230
2227
- if (I.getIntrinsicID () != Intrinsic::minnum)
2231
+ Intrinsic::ID IID = I.getIntrinsicID ();
2232
+
2233
+ // The value is only used in contexts where we know the input isn't a nan, so
2234
+ // any of the fmin variants are fine.
2235
+ if (IID != Intrinsic::minnum &&
2236
+ IID != Intrinsic::minimumnum & IID != Intrinsic::minimum)
2228
2237
return nullptr ;
2229
2238
2230
2239
Type *Ty = I.getType ();
@@ -2270,7 +2279,7 @@ Value *AMDGPUCodeGenPrepareImpl::applyFractPat(IRBuilder<> &Builder,
2270
2279
return insertValues (Builder, FractArg->getType (), ResultVals);
2271
2280
}
2272
2281
2273
- bool AMDGPUCodeGenPrepareImpl::visitMinNum (IntrinsicInst &I) {
2282
+ bool AMDGPUCodeGenPrepareImpl::visitFMinLike (IntrinsicInst &I) {
2274
2283
Value *FractArg = matchFractPat (I);
2275
2284
if (!FractArg)
2276
2285
return false ;
0 commit comments