This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Make type for lower action more consistently optional
ClosedPublic

Authored by arsenm on Jul 15 2020, 9:07 AM.

Details

Summary

Some of the lower implementations were relying on this, however the
type was not set depending on which form .lower* helper form you were
using. For instance, if you used an unconditonal lower(), the type was
never set. Most of the lower actions do not benefit from a type
parameter, and just expand in terms of the original operation's types.

However, some lowerings could benefit from an additional type hint to
combine a promotion and an expansion. An example of this is for
add/sub sat. The DAG integer legalization tries to use smarter
expansions directly when promoting the integer type, and doesn't always
produce the same instruction with a wider type.

Treat this as an optional hint argument, that only means something for
specific lower actions. It may be useful to generalize this mechanism
to pass a full list of type indexes and desired types, but I haven't
run into a case like that yet.

Diff Detail

Event Timeline

arsenm created this revision.Jul 15 2020, 9:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2020, 9:07 AM

Is it possible to write a testcase for this?

Is it possible to write a testcase for this?

This doesn’t change anything on its own. All of the existing lower implementations have tests already. I’m working on a follow on patch beyond D73051 which will use this to pass a different type in

Is the intention of the type arg to be something to only attempt to get to, or something that's expected to lower to otherwise there's a legalization failure?

Is the intention of the type arg to be something to only attempt to get to, or something that's expected to lower to otherwise there's a legalization failure?

I was thinking of it as a hint, not required. It doesn't necessarily mean anything for all lowerings.

For the purpose of this change alone, there's no use of the type parameter. This just fixes lower working or not depending on which path you set the legalizer rule through

aemerson added inline comments.Aug 17 2020, 10:55 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
2330

I suggest renaming this to something like LowerHintTy to make it clear it.

4381

These changes look orthogonal to the main patch?

arsenm added inline comments.Aug 17 2020, 11:00 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
4381

No, this switches from using the type parameter (which was sometimes invalid) to taking the types from the register operands. This was also incorrectly assuming the result type and the source type were the same

aemerson accepted this revision.Aug 17 2020, 11:37 AM

Alright, LGTM with the name change.

This revision is now accepted and ready to land.Aug 17 2020, 11:37 AM
arsenm closed this revision.Aug 17 2020, 1:25 PM
arsenm marked an inline comment as done.

a128292b90189ca3b802e9035f896e9b454ce366 with some pruned dead arguments