This patch is to support combining of rlwinm + rlwinm to one rlwinm.
For example:
x3 = rlwinm x3, 27, 5, 31 x3 = rlwinm x3, 19, 0, 12
can be combined to
x3 = rlwinm x3, 14, 0, 12
Paths
| Differential D70374
[PowerPC] combine rlwinm + rlwinm to rlwinm ClosedPublic Authored by shchenz on Nov 18 2019, 12:10 AM.
Details
Summary This patch is to support combining of rlwinm + rlwinm to one rlwinm. x3 = rlwinm x3, 27, 5, 31 x3 = rlwinm x3, 19, 0, 12 can be combined to x3 = rlwinm x3, 14, 0, 12
Diff Detail
Event Timeline
Comment Actions LGTM with some minor nit. But please wait for some days if some one else have more comments.
This revision is now accepted and ready to land.Nov 18 2019, 7:37 PM shchenz marked 2 inline comments as done. Comment Actionsfix @steven.zhang comment and rebase after https://reviews.llvm.org/D69032 committed. Closed by commit rG29f6f9b2b2bf: [PowerPC] combine rlwinm+rlwinm to rlwinm combine x3 = rlwinm x3, 27, 5, 31 x3… (authored by shchenz). · Explain WhyNov 21 2019, 9:09 PM This revision was automatically updated to reflect the committed changes. Comment Actions This patch caused failure in http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/21918 Narrow down case: #define rlwinm( output, input, sh, mb, me ) \ __asm__( "rlwinm %0, %1, %2, %3, %4" \ : "=r"(output) \ : "r"(input), "i"(sh), "i"(mb), "i"(me) \ : ) int main() { long x = 0x1122334455667788L ; long y ; long z; rlwinm( y, x, 1, 0, 30) ; rlwinm( z, y, 31, 1, 0) ; printf("0x%016lX -> 0x%016lX -> 0x%016lX\n", x, y, z) ; return 0 ; } We should get result: 0x1122334455667788 -> 0x00000000AACCEF10 -> 0x5566778855667788 But with this patch, y = RLWINM x, 1, 0, 30 z = RLWINM y, 31, 1, 0 We will convert z to z = LI 0, this is not right. This revision is now accepted and ready to land.Nov 27 2019, 12:42 AM This revision is now accepted and ready to land.Nov 28 2019, 5:24 PM Comment Actions LGTM. Thanks for fixing it. Personally, I would recommend Alive to verify peephole optimizations. This revision is now accepted and ready to land.Dec 2 2019, 1:31 AM Closed by commit rGf0ba1aec35d5: [PowerPC] folding rlwinm + rlwinm to rlwinm (authored by shchenz). · Explain WhyDec 3 2019, 6:55 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 232026 llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
llvm/test/CodeGen/PowerPC/fold-rlwinm-1.ll
llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
|
Personally, I prefer to add a else here to make the code more clear, then, you don't need the break in line 871 any more. Anyway, it depends on you.