This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG][AArch64] Legalize FMAXIMUM/FMINIMUM
ClosedPublic

Authored by anna on Jun 12 2023, 8:57 AM.

Details

Summary

The missing legalization in SelectionDAG was identified when adding the
intrinsic support for vector reduction for maximum/minimum (D152370).

Fixes PR: https://github.com/llvm/llvm-project/issues/63267

Diff Detail

Event Timeline

anna created this revision.Jun 12 2023, 8:57 AM
anna requested review of this revision.Jun 12 2023, 8:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2023, 8:57 AM
nikic added inline comments.Jun 12 2023, 9:04 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
4177

These libcalls follow the semantics of FMINNUM/FMAXNUM, we can't reuse them for FMINIMUM/FMAXIMUM.

I don't think there are any libcalls for this, so I think we need to always expand as a fallback, not libcall legalize. Of course, that runs into the problem that we don't even have a default expansion for these nodes...

4958

This part should be fine.

anna added inline comments.Jun 12 2023, 9:11 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
4177

Yes, I thought this RTLIB call might be a problem... and couldn't find any for maximum/minimum.
I'll document this as an existing bug within the legalization under the original PR and state what you've added here.
This also means the vector reduce legalization for f128 and friends described here would not have legalization. I would like to avoid blocking the introduction of the vector reduction intrinsic on that though.

nikic added inline comments.Jun 12 2023, 9:12 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
4177

That's fine. For the purpose of introducing the reduction intrinsics, you can just leave the test cases that currently don't work commented out. These are really independent problems.

anna updated this revision to Diff 530541.Jun 12 2023, 9:16 AM

addressed review comment. Left in a comment to explain why we cannot legalize using libcalls for F128 and friends.

nikic accepted this revision.Jun 12 2023, 9:17 AM

LGTM

This revision is now accepted and ready to land.Jun 12 2023, 9:17 AM
anna added a comment.Jun 12 2023, 9:21 AM

thanks for quick review @nikic!

This revision was landed with ongoing or failed builds.Jun 12 2023, 9:24 AM
This revision was automatically updated to reflect the committed changes.