This is an archive of the discontinued LLVM Phabricator instance.

InstCombine: Fold is.fpclass nan|zero to fcmp ueq 0
ClosedPublic

Authored by arsenm on Mar 15 2023, 8:25 AM.

Diff Detail

Event Timeline

arsenm created this revision.Mar 15 2023, 8:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2023, 8:25 AM
arsenm requested review of this revision.Mar 15 2023, 8:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2023, 8:25 AM
Herald added a subscriber: wdng. · View Herald Transcript
kpn added a comment.Mar 15 2023, 8:35 AM

Where is fpclassTestIsFCmp0 implemented?

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
881–882

Any chance we can be consistent with formatting? The check for !IsStrict was formatted consistently before. Pedantic, perhaps, but it jumped out at me.

Where is fpclassTestIsFCmp0 implemented?

In 4109e3f1db4e0024c87f01cf20dd19ad85779e37

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
881–882

This is what clang-format did

886–893

There might be a bug here if the test mask only included snan or qnan individually

arsenm updated this revision to Diff 505629.Mar 15 2023, 2:36 PM

Fix case with only a single nan test enabled

foad added inline comments.Mar 17 2023, 2:37 AM
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
885

This will have high bits set so how does it ever match any of the tests in fpclassTestIsFCmp0? Is there a test for that?

I think it should be OrderedInvertedMask = ~Mask & fcAll & ~fcNan. "Ordered inverted mask" seems more correct than "Inverted ordered mask".

arsenm added inline comments.Mar 17 2023, 4:43 AM
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
885

BitmaskEnum's operators hide the clearing of the high bits for you

arsenm updated this revision to Diff 506045.Mar 17 2023, 5:11 AM

Rename variable

foad accepted this revision.Mar 17 2023, 7:37 AM
This revision is now accepted and ready to land.Mar 17 2023, 7:37 AM

I somehow squashed the next one when fixing a conflict, reverted and resubmitted as 80512789b6debb228754b1729cd4c86906a15082