This is an archive of the discontinued LLVM Phabricator instance.

InstCombine: Fold is.fpclass for single infinity to fcmp
ClosedPublic

Authored by arsenm on Mar 15 2023, 2:53 PM.

Details

Summary

llvm.is.fpclass(x, fcPosInf) -> fcmp oeq x, +inf
llvm.is.fpclass(x, fcNegInf) -> fcmp oeq x, -inf
llvm.is.fpclass(x, ~fcPosInf) -> fcmp one x, +inf
llvm.is.fpclass(x, ~fcNegInf) -> fcmp one x, -inf

llvm.is.fpclass(x, fcPosInf|fcNan) -> fcmp ueq x, +inf
llvm.is.fpclass(x, fcNegInf|fcNan) -> fcmp ueq, -inf
llvm.is.fpclass(x, ~fcPosInf & ~fcNan) -> fcmp one, x, +inf
llvm.is.fpclass(x, ~fcNegInf & ~fcNan) -> fcmp one, x, -inf

This regresses some of the logic of fcmp tests. These should be restored
in a future patch to better handle combining logic of fcmp and class.

Diff Detail

Event Timeline

arsenm created this revision.Mar 15 2023, 2:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2023, 2:53 PM
arsenm requested review of this revision.Mar 15 2023, 2:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2023, 2:53 PM
Herald added a subscriber: wdng. · View Herald Transcript
foad added a comment.Mar 17 2023, 2:39 AM

From the description:

llvm.is.fpclass(x, fcPosInf) -> fcmp oeq x, +inf
llvm.is.fpclass(x, fcNegInf) -> fcmp oeq x, -inf
llvm.is.fpclass(x, ~fcPosInf) -> fcmp one x, +inf
llvm.is.fpclass(x, ~fcNegInf) -> fcmp one x, -inf

The last two should be "une".

foad added inline comments.Mar 17 2023, 2:41 AM
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
889–892
arsenm updated this revision to Diff 506046.Mar 17 2023, 5:14 AM
arsenm marked an inline comment as done.
foad accepted this revision.Mar 17 2023, 7:42 AM
This revision is now accepted and ready to land.Mar 17 2023, 7:42 AM