This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] [NFC] Cleanup xxpermdi peephole optimization
ClosedPublic

Authored by vddvss on Dec 7 2019, 3:06 PM.

Details

Summary

Following on from rG884351547da2, this patch cleans up the logic for xxpermdi
peephole optimizations by converting two layers of nested ifs to early breaks
and simplifying the logic.

Diff Detail

Event Timeline

vddvss created this revision.Dec 7 2019, 3:06 PM

Please attach the test if it is NOT NFC patch, otherwise, adding a tag [NFC] in the title, thank you.

vddvss retitled this revision from [PowerPC] Cleanup xxpermdi peephole optimization to [PowerPC] [NFC] Cleanup xxpermdi peephole optimization.Dec 8 2019, 6:26 PM

Please attach the test if it is NOT NFC patch, otherwise, adding a tag [NFC] in the title, thank you.

Oops, sorry about that. Yes, it is an NFC patch covered by existing tests.

steven.zhang accepted this revision.Dec 8 2019, 10:41 PM

LGTM, as early return makes the code more clear. Thank you for the clean up.

This revision is now accepted and ready to land.Dec 8 2019, 10:41 PM
vddvss added a comment.Dec 9 2019, 6:33 AM

LGTM, as early return makes the code more clear. Thank you for the clean up.

Thanks! Could you land it for me please?

jsji added inline comments.Dec 9 2019, 12:01 PM
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
350

Looks like this might have a problem with Stack slots? We used to only handle virtual registers,
but now, we might also let throughg stack slots (and Not a register), which might cause build break?

//   0           Not a register, can be used as a sentinel.
//   [1;2^30)    Physical registers assigned by TableGen.
//   [2^30;2^31) Stack slots. (Rarely used.)
//   [2^31;2^32) Virtual registers assigned by MachineRegisterInfo.
vddvss added inline comments.Dec 9 2019, 12:12 PM
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
350

Oh, I didn't know about that. I had used isPhysicalRegister based on the pattern in D69497. Should I change this or both of them to !isVirtualRegister?

jsji added inline comments.Dec 9 2019, 12:23 PM
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
350

I think so, it is the simplest NFC change. Or else you should go through following code to double check, may sure it won't break anything.

vddvss updated this revision to Diff 232915.Dec 9 2019, 1:07 PM
vddvss marked an inline comment as done.

This addresses @jsji's note about the potential for stack slots being let through by using isPhysicalRegister. It changes this pattern and the one from D69497 to use !isVirtualRegister.

jsji added a comment.Dec 9 2019, 1:32 PM

Thanks. I will commit it for you.

This revision was automatically updated to reflect the committed changes.
steven.zhang added inline comments.Dec 9 2019, 6:06 PM
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
350

Ah, good catch. ! isVirtualRegister != isPhysicalRegister ...