This is an archive of the discontinued LLVM Phabricator instance.

[X86][FP16] Combine two steps conversions into direct conversion
ClosedPublic

Authored by pengfei on Feb 12 2023, 6:58 PM.

Details

Summary

When both v8i64 and v4f16 are not legal in a v8i64->v8f16 conversion, legalizer will breaks it into v8i64->v4i64->v4f32->v8f32->v8f16.

Given we support v4i64->v8f16, we can combine them with a shuffle instruction.

Diff Detail

Event Timeline

pengfei created this revision.Feb 12 2023, 6:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 12 2023, 6:58 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
pengfei requested review of this revision.Feb 12 2023, 6:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 12 2023, 6:58 PM
pengfei updated this revision to Diff 496826.Feb 12 2023, 7:02 PM

Fix a mistake.

LuoYuanke added inline comments.Feb 12 2023, 7:58 PM
llvm/lib/Target/X86/X86ISelLowering.cpp
56704

Should we check the number of operands of concat be 2?

56717

Not sure we can transform the node for strict fp operation.

56719

Should we make sure opc is a xint_to_fp node, otherwise return SDValue()?

56728

Ditto.

56736

Why move the check after line 56701?

pengfei marked an inline comment as done.Feb 13 2023, 12:16 AM
pengfei added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
56704

concat has at least 2 operands. Given we have checked the dest is v8f16 and both source come from v4i64, I think we don't need to check it.

56717

The transform is strict fp compliance. There are totally two different exceptions in this case: precision and overflow. A value out of range of f16 will set both exceptions. A precision exception in i64->f32 always means the value out of range of f16. So we won't discard of introduce any exceptions.

56719

We make sure it's xint_to_fp because we have checked the result type is f32 and input type is i64.

56736

Reuse the code in 56693 line to check src and dst type.

This revision is now accepted and ready to land.Feb 13 2023, 4:33 AM
This revision was landed with ongoing or failed builds.Feb 13 2023, 6:58 AM
This revision was automatically updated to reflect the committed changes.