This is an archive of the discontinued LLVM Phabricator instance.

[NFC][PowerPC] Clean up a couple of lambdas from the PPCMIPeephole.
ClosedPublic

Authored by stefanp on Aug 22 2022, 9:57 AM.

Details

Summary

There were two sections of code that had a lot of lambdas and in the patch
D40554 it was suggested that we clean them up as a follow-up NFC patch.

Diff Detail

Event Timeline

stefanp created this revision.Aug 22 2022, 9:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2022, 9:57 AM
stefanp requested review of this revision.Aug 22 2022, 9:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2022, 9:57 AM
stefanp added a reviewer: Restricted Project.Aug 22 2022, 9:58 AM
nemanjai accepted this revision.Aug 23 2022, 4:04 AM

I don't think another review cycle is needed to address the slight change I proposed.

llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
792–797

I think that even converting the lambdas into just Boolean variables might make it more readable. Something like:

bool SourceIsXForm = SrcOpcode == PPC::LHZX;
bool MIIs64Bit = MI.getOpcode() == PPC::EXTSH8 ||
  MI.getOpcode() == PPC::EXTSH8_32_64;

if (SourceIsXForm && MIIs64Bit)
  Opc = PPC::LHAX8;
else if (SourceIsXForm && !MIIs64Bit)
  Opc = PPC::LHAX;
else if (MIIs64Bit)
  Opc = PPC::LHA8;
This revision is now accepted and ready to land.Aug 23 2022, 4:04 AM
stefanp updated this revision to Diff 454900.Aug 23 2022, 11:03 AM

Used booleans to make the if statements more clear.
Rebased to top of main branch.

This revision was landed with ongoing or failed builds.Aug 23 2022, 11:09 AM
This revision was automatically updated to reflect the committed changes.