This is an archive of the discontinued LLVM Phabricator instance.

[SVE ACLE] Extend IR combines for fmul, fsub, fadd to cover _u variants
ClosedPublic

Authored by jolanta.jensen on May 17 2023, 3:53 AM.

Details

Summary

This patch extends existing IR combines for: fmul, fsub and fadd,
relying on all active predicate to also apply to their equivalent
undef (_u) intrinsics.

Diff Detail

Event Timeline

jolanta.jensen created this revision.May 17 2023, 3:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 3:53 AM
jolanta.jensen requested review of this revision.May 17 2023, 3:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 3:53 AM
Matt added a subscriber: Matt.May 17 2023, 10:26 AM

Corrections to the very first patch.
Added tests as well.

mgabka added inline comments.May 19 2023, 4:17 AM
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
1707

Hi Jolanta,
I think that code like:

if (auto Replacement = instCombineSVEVectorBinOp(IC, II))

return Replacement;

return instCombineSVEVectorFuseMulAddSub

would be more readable here.

Some refactoring. More tests added.

This patch for now covers only fadd/fadd_u, fsub/fsub_u and fmul/fmul_u, what about other intrinsics which are having both merging and _u variants I thought we want to replace all merging forms with _u forms when the predicate is all true ? @paulwalker-arm what is your opinion here?

llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-fmul_u-idempotency.ll
4

the test in this file do not match the description of the commit message, I think that is an optimization we want to cover separately, @paulwalker-arm wjhat is your opinion?

Implemented IR combines to convert _m intrinsics that take an all active predicate to their equivalent _u intrinsic.

This patch for now covers only fadd/fadd_u, fsub/fsub_u and fmul/fmul_u, what about other intrinsics which are having both merging and _u variants I thought we want to replace all merging forms with _u forms when the predicate is all true ? @paulwalker-arm what is your opinion here?

This patch is concerned with extending existing combines rather than adding new ones. I do agree the summary should be better worded to reflect this.

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
1303–1304

Is it possible to maintain the original structure of this function by just adding the new instCombineSVEVectorFuseMulAddSub entry for aarch64_sve_fmul_u? e.g.

if (auto FMLA_U =
        instCombineSVEVectorFuseMulAddSub<Intrinsic::aarch64_sve_fmul_u,
                                          Intrinsic::aarch64_sve_fmla_u>(
            IC, II, true))
  return FMLA_U;
return instCombineSVEVectorBinOp(IC, II);
1327–1328

Same comment as above relating to maintain the function original structure.

1338

I'd rather the instCombineSVEAllActive2VA and instCombineSVEAllActive3VA changes be rolled into a separate patch. That way we have this patch focusing on the existing combines that are being ported to include the newer intrinsics and then a following patch to add new combines for everything else.

llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-fma-binops.ll
199

Do you mind moving this negative test so it appears after the three positive ones?

llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-fmul_u-idempotency.ll
4

@mgabka: This patch is about extending existing combines to also cover their equivalent _u intrinsics. The majority relate to replacing intrinsic calls with IR instructions but instCombineSVEVectorMul contains more combines. I think it would be messier to try to artificially avoid these combines so am happy for this patch to include them, assuming they're genuinely applicable? with this patch adding the relevant tests.

Removed IR combines as they will go to another patch.
Addressed review comments.

jolanta.jensen retitled this revision from [SVE ACLE] Canonicalise SVE merging intrinsics to [SVE ACLE] Canonicalise SVE merging intrinsics -- part 1.Jun 1 2023, 6:31 AM
jolanta.jensen edited the summary of this revision. (Show Details)
jolanta.jensen added inline comments.Jun 1 2023, 6:37 AM
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
1303–1304

Yes, there was no fallout from the move. It looks much better now.

1327–1328

Fixed.

1338

Removed IR combines from this patch.

llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-fmul_u-idempotency.ll
4

It looks like this test and sve-intrinsic-fma-binops.ll cover all paths taken in instCombineSVEVectorMul.

jolanta.jensen added inline comments.Jun 1 2023, 6:40 AM
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-fma-binops.ll
199

Fixed.

paulwalker-arm accepted this revision.Jun 1 2023, 10:00 AM
This revision is now accepted and ready to land.Jun 1 2023, 10:00 AM
jolanta.jensen retitled this revision from [SVE ACLE] Canonicalise SVE merging intrinsics -- part 1 to [SVE ACLE] Extend IR combines for fmul, fsub, fadd to cover _u variants.Jun 2 2023, 3:23 AM
jolanta.jensen edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Jun 2 2023, 4:08 AM
This revision was automatically updated to reflect the committed changes.