This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] remove side effect for some cases for saturate instructions
ClosedPublic

Authored by shchenz on Mar 5 2023, 10:29 PM.

Diff Detail

Event Timeline

shchenz created this revision.Mar 5 2023, 10:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2023, 10:29 PM
shchenz requested review of this revision.Mar 5 2023, 10:29 PM
nemanjai added inline comments.Mar 6 2023, 5:35 AM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
15790–15822

Can you please do the following two things:

  1. Add a comment explaining that these sum-across intrinsics only have a chain due to the side effects. If we know that the SAT bit will not be set, we can replace any uses of their chain with the input chain.
  2. Combine these into a single switch - along the lines of:
switch (cast<ConstantSDNode>(N->getOperand(1))->getZExtValue()) {
case Intrinsic::ppc_vsx_lxvw4x:
case Intrinsic::ppc_vsx_lxvd2x:
  if (Subtarget.needsSwapsForVSXMemOps())
    return expandVSXLoadForLE(N, DCI);
  break;
case Intrinsic::ppc_altivec_vsum4sbs:
case Intrinsic::ppc_altivec_vsum4shs:
case Intrinsic::ppc_altivec_vsum4ubs: {
  // handle the chain replacement
}
}
shchenz updated this revision to Diff 502896.Mar 6 2023, 6:32 PM
shchenz marked an inline comment as done.

address @nemanjai comments

gentle ping @nemanjai . Do you have further comments? Thank you!

nemanjai accepted this revision.Mar 13 2023, 5:22 AM

LGTM. I don't think that the test improvement requires another review.

llvm/test/CodeGen/PowerPC/vector-sum-sat-bit-side-effect.ll
12

I think it would be more useful to add a use of the actual sum in at least one of the tests. The test would have one call that is used and one that is unused. Previous to this patch, we would emit both and with this patch, we only emit the one that is used.

This revision is now accepted and ready to land.Mar 13 2023, 5:22 AM
shchenz marked an inline comment as done.Mar 13 2023, 6:21 PM
shchenz added inline comments.
llvm/test/CodeGen/PowerPC/vector-sum-sat-bit-side-effect.ll
12

Sure, I will add 3 new cases in the commit. And these cases will contains two calls, one call has user and one call has no user, so this call can be optimized by this patch.

This revision was landed with ongoing or failed builds.Mar 13 2023, 6:38 PM
This revision was automatically updated to reflect the committed changes.
shchenz marked an inline comment as done.