This is an archive of the discontinued LLVM Phabricator instance.

[GVN/FP] Considate logic for reasoning about equality vs equivalance for floats
ClosedPublic

Authored by reames on Sep 3 2019, 1:40 PM.

Details

Summary

Factor out common logic into some reasonable commented helper functions. In the process, ensure that the in-block vs cross-block cases are handled the same. They previously weren't.

(Carefully review here would be appreciated. I'm by no means a floating point expert and am going solely off existing comments and LangRef.)

Diff Detail

Event Timeline

reames created this revision.Sep 3 2019, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2019, 1:40 PM
xbolva00 added inline comments.
lib/Transforms/Scalar/GVN.cpp
1429 ↗(On Diff #218529)

Cmp->getFastMathFlags().noSignedZeros() ?

reames marked an inline comment as done.Sep 3 2019, 2:00 PM
reames added inline comments.
lib/Transforms/Scalar/GVN.cpp
1429 ↗(On Diff #218529)

a) I just moved the todo
b) See the comment about not considering myself particularly FP knowledgeable.

xbolva00 added inline comments.Sep 3 2019, 2:05 PM
lib/Transforms/Scalar/GVN.cpp
1429 ↗(On Diff #218529)

Ok, no problem

arsenm added a subscriber: arsenm.Sep 3 2019, 2:20 PM
arsenm added inline comments.
lib/Transforms/Scalar/GVN.cpp
1394 ↗(On Diff #218529)

Spelling, equivalent

1407–1408 ↗(On Diff #218529)

This won't handle vectors

1429 ↗(On Diff #218529)

I think you are looking for llvm::CannotBeNegativeZero

fhahn accepted this revision.Dec 5 2019, 10:36 AM

LGTM. Could you add a TODO to handle vector constants? It seems this is used on code paths that would also see vector fcmps, so it would be good to address this as follow up.

Please wait a few days with committing, in case @scanon or anyone else has any additional feedback.

test/Transforms/GVN/edge.ll
96 ↗(On Diff #218529)

Could you add a few additional tests for ueq?

This revision is now accepted and ready to land.Dec 5 2019, 10:36 AM
This revision was automatically updated to reflect the committed changes.