Skip to content

[AMDGPU][True16][CodeGen] legalize operands when move16bit SALU to VALU #133985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

broxigarchen
Copy link
Contributor

@broxigarchen broxigarchen commented Apr 1, 2025

This is a follow up PR from #132089.

When a V2S copy and its useMI are lowered to VALU, this patch check:
If the generated new VALU is a true16 inst. Add subreg access on all operands if necessary.

an example MIR looks like:

%1:vgpr_32 = V_CVT_F32_U32_e64 %0:vgpr_32, 0, 0 ...
%2:sreg_32 = COPY %1:vgpr_32
%3:sreg_32 = S_FLOOR_F16 %2:sreg_32, ...

currently lowered to

%1:vgpr_32 = V_CVT_F32_U32_e64 %0:vgpr_32, 0, 0 ...
%2:vgpr_16 = V_FLOOR_F16_t16_e64 0, %1:vgpr_32, 0, 0, 0 ...

after this patch

%1:vgpr_32 = V_CVT_F32_U32_e64 %0:vgpr_32, 0, 0 ...
%2:vgpr_16 = V_FLOOR_F16_t16_e64 0, %1.lo16:vgpr_32, 0, 0, 0 ...

@broxigarchen broxigarchen force-pushed the main-merge-true16-codegen-fix-spgr-lower-2 branch from ccf5cae to cd35479 Compare April 1, 2025 20:49
@broxigarchen broxigarchen changed the title legalize movetoVALU operand in true16 [AMDGPU][True16][CodeGen] fix moveToVALU operand with proper subreg access in true16 Apr 1, 2025
@broxigarchen broxigarchen marked this pull request as ready for review April 1, 2025 21:10
@broxigarchen broxigarchen force-pushed the main-merge-true16-codegen-fix-spgr-lower-2 branch from cd35479 to 5f0a838 Compare April 1, 2025 21:59
@broxigarchen broxigarchen changed the title [AMDGPU][True16][CodeGen] fix moveToVALU operand with proper subreg access in true16 [AMDGPU][True16][CodeGen] legalize operands when lower 16bit SALU to VALU Apr 1, 2025
@broxigarchen broxigarchen changed the title [AMDGPU][True16][CodeGen] legalize operands when lower 16bit SALU to VALU [AMDGPU][True16][CodeGen] legalize operands when move16bit SALU to VALU Apr 1, 2025
Copy link
Contributor

@Sisyph Sisyph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@broxigarchen broxigarchen merged commit bf388f8 into llvm:main Apr 3, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants