This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] replace rlwinm operand 1 with src rlwinm operand 1
ClosedPublic

Authored by shchenz on Dec 25 2019, 7:24 PM.

Details

Summary

This is split from https://reviews.llvm.org/D71833.

After folding rlwinm, forget to replace result rlwinm operand 1 with src rlwinm operand 1.

By doing this, we can eliminate more src rlwinm.

Diff Detail

Event Timeline

shchenz created this revision.Dec 25 2019, 7:24 PM
steven.zhang added inline comments.Dec 29 2019, 10:41 PM
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
894

it is not
s/and/or
it is safe

896

You don't need to check it here. Please move to line 964 and remove it if its use is 0.

MaskRay added inline comments.
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
958

The coding standard uses pre-increment operators.

llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
136

This -NOT pattern is too specific. Do you intend to make it general so that it can catch more problems if the exact instruction changes a bit in the future?

shchenz updated this revision to Diff 235565.Dec 30 2019, 1:28 AM
shchenz marked 5 inline comments as done.

address comments

llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
136

Good Idea!

steven.zhang requested changes to this revision.Dec 30 2019, 1:55 AM

The RLWINMo should also be removed,

llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
962

You don't need to check the opcode any more and it will fix the missing case of

RLWINM
RLWINMo -->

ANDIo
llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
136

No. This is NOT right. What you are checking is the removal of RLWINM, instead of %2:gprc. You can do it as:

; CHECK-NOT: RLWINM {regex here}, 27
136–137

Why the RLWINMo is still here ?

This revision now requires changes to proceed.Dec 30 2019, 1:55 AM
steven.zhang added inline comments.Dec 30 2019, 2:08 AM
llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
136–137

Ah, sorry. I didn't notice that, you are replacing it with ANDIo. So, it is fine. But I still don't agree with checking the symbol register number which is vulnerable.

shchenz marked an inline comment as done.Dec 30 2019, 2:12 AM
shchenz added inline comments.
llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
136–137

Here what we check is that original input for MI (%2) is not needed? I am glad if you can point out why Check-not %2 is not good?

shchenz marked an inline comment as done.Dec 30 2019, 2:26 AM
shchenz added inline comments.
llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
136–137

If we do something wrongly in future to change 2% to the result of other opcode, we should still can eliminate it. This can only caught by current CHECK-NOT, but can not checked by CHECK-NOT %2 RLWINM? @steven.zhang?

steven.zhang added inline comments.Dec 30 2019, 3:52 AM
llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
136–137

Your test point should align with your implementation. If it is change to other opcode in the future, it is hard to say if it is right or wrong as it is not your test point. And besides, the symbolic register is subject to change.

shchenz marked an inline comment as done.Dec 30 2019, 4:18 AM
shchenz added inline comments.
llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
136–137

Yes, the test point here is we should eliminate instruction %2:gprc = RLWINM %1:gprc, 27, 5, 10, so IMO it is ok to check if %2:gprc is stilled defined/used. And %2:gprc is got from test case input, so I guess if any change wants to change the input symbolic register, it must be aware that the input symbolic register is used in checking lines.

shchenz updated this revision to Diff 235808.Jan 1 2020, 5:47 PM

update testing point

steven.zhang added inline comments.Jan 1 2020, 10:00 PM
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
962

Can we use the check of SrcMI->hasImplicitDef() instead of enumerating the opcode to be more flexible ?

shchenz updated this revision to Diff 235984.Jan 2 2020, 6:12 PM

address @steven.zhang comments

steven.zhang accepted this revision.Jan 5 2020, 6:43 PM

LGTM. But please hold on some days in case someone else has other comments.

This revision is now accepted and ready to land.Jan 5 2020, 6:43 PM
This revision was automatically updated to reflect the committed changes.