This is an archive of the discontinued LLVM Phabricator instance.

[FPEnv][InstSimplify] Fold fadd X, 0 ==> X, when we know X is not -0
ClosedPublic

Authored by kpn on Oct 8 2021, 11:38 AM.

Details

Summary

Currently the fadd optimizations in InstSimplify don't know how to do this NoSignedZeros "X + 0.0 ==> X" fold when using the constrained intrinsics. This adds the support.

This review is derived from D106362 with some improvements from D107285 and is a follow-on to D111085.

Diff Detail

Event Timeline

kpn requested review of this revision.Oct 8 2021, 11:38 AM
kpn created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2021, 11:38 AM
spatel added inline comments.Oct 11 2021, 2:13 PM
llvm/test/Transforms/InstSimplify/strictfp-fadd.ll
303

Don't we want a test without nnan where exceptions are ignored but is not the default FP env?

Ie, this should fold?

%add = call nsz float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.downward", metadata !"fpexcept.ignore") #0
kpn added inline comments.Oct 13 2021, 10:05 AM
llvm/test/Transforms/InstSimplify/strictfp-fadd.ll
303

Yes, that's a good idea. And, yes, I believe we do want this to fold. The "nsz" flag means (I think) that if "x" is zero the sign of "0 - 0" is insignificant. I think that's what that means, anyway.

kpn updated this revision to Diff 379447.Oct 13 2021, 10:08 AM

As requested, add tests for rounding to negative infinity, exceptions ignored, no sized zeros fast math flag.

spatel accepted this revision.Oct 14 2021, 6:00 AM

LGTM

This revision is now accepted and ready to land.Oct 14 2021, 6:00 AM
This revision was landed with ongoing or failed builds.Oct 14 2021, 9:33 AM
This revision was automatically updated to reflect the committed changes.