llvm-project
0febabd5 - [AMDGPU][GlobalISel] Use carry chains when narrowing a multiply-high (#238389)

Commit
1 day ago
[AMDGPU][GlobalISel] Use carry chains when narrowing a multiply-high (#238389) When a G_UMULH or G_SMULH is narrowed and G_UADDE is legal for the narrow type, accumulate the partial products row by row with G_UADDO/G_UADDE carry chains, following `TargetLowering::expandMUL_LOHI`, instead of zero-extending and summing each carry. Each row `a[i] * b` is built as NumParts + 1 parts and added into a running sum, and the top additions of each step cannot overflow. G_MUL, and targets without a legal G_UADDE, keep using `multiplyRegisters`. For an s64 G_UMULH narrowed to s32, this replaces 5 G_UADDO, 5 G_ZEXT and 4 G_ADD with 3 G_UADDO and 4 G_UADDE. An s128 G_UMULH narrowed to s32 uses 7 G_UADDO and 24 G_UADDE, with no G_ZEXT.
Author
Parents
Loading