This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Use legal shift amount type in DAGTypeLegalizer::JoinIntegers
ClosedPublic

Authored by foad on Jul 11 2023, 6:30 AM.

Details

Summary

Documentation for TargetLowering::getShiftAmountTy says that LegalTypes
should generally be true during type legalization, so this patch does
that.

On AMDGPU the effect is that we use i32 (a sane type) instead of i64
(pointer sized type) for more shift amounts, which in turn allows more
formation of rotates and funnel shifts pre-legalization.

Diff Detail

Event Timeline

foad created this revision.Jul 11 2023, 6:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 6:30 AM
foad requested review of this revision.Jul 11 2023, 6:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 6:30 AM
arsenm accepted this revision.Jul 11 2023, 6:34 AM
arsenm added a subscriber: arsenm.

LGTM. I don't think this pararameter makes any sense to begin with

This revision is now accepted and ready to land.Jul 11 2023, 6:34 AM
foad added reviewers: Restricted Project, RKSimon, craig.topper.Jul 11 2023, 6:36 AM
foad added inline comments.
llvm/test/CodeGen/AMDGPU/permute_i8.ll
220

A bunch of regressions like this seem to be related to worse use of v_perm.

foad planned changes to this revision.Jul 11 2023, 6:36 AM

I'll work on the regressions.

foad updated this revision to Diff 539133.Jul 11 2023, 8:46 AM

Avoid AMDGPU v_perm regressions by matching BSWAP.

This revision is now accepted and ready to land.Jul 11 2023, 8:46 AM
arsenm accepted this revision.Jul 11 2023, 11:33 AM
foad added inline comments.Jul 12 2023, 12:12 AM
llvm/test/CodeGen/AMDGPU/scalar_to_vector.ll
109

There are still some minor regressions like this one, but I'm inclined to waive them. In this case the v_and is redundant because the result is the same as v1. SimplifyDemandedBits would normally optimize this but in this case it gives up because v2 has multiple uses: https://github.com/llvm/llvm-project/blob/49364503f621d807c4ee80050ab7a0cdb2b05a60/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp#L1116