This is an archive of the discontinued LLVM Phabricator instance.

Codegen: [PPC] Word Rotates are Zero Extending
ClosedPublic

Authored by iteratee on Mar 1 2016, 2:04 PM.

Details

Summary

Add Word rotates to the list of instructions that are zero extending.
This allows them to be used in dot form to compare with zero.

Diff Detail

Event Timeline

iteratee updated this revision to Diff 49547.Mar 1 2016, 2:04 PM
iteratee retitled this revision from to Codegen: [PPC] Word Rotates are Zero Extending.
iteratee updated this object.
iteratee added a reviewer: kbarton.
iteratee set the repository for this revision to rL LLVM.
iteratee added subscribers: echristo, timshen, llvm-commits.

Testcase?

OK with one of those. :)

-eric

hfinkel requested changes to this revision.Mar 1 2016, 2:30 PM
hfinkel added a reviewer: hfinkel.
hfinkel added a subscriber: hfinkel.

I don't think this is right. RLWINM starts by taking two copies of the 32-bit amount, one copy in the lower word and one copy in the upper word and rotates the result, Then it composes the mask. The mask is non-zero in the upper bits if MB >= ME.

This revision now requires changes to proceed.Mar 1 2016, 2:30 PM

You're right. We came up with the usual case, but not the normal case. Kyle
is going to add a check for the arguments as well :)

-eric

Also why testcases are awesome :)

-eric

iteratee updated this revision to Diff 49658.Mar 2 2016, 12:09 PM
iteratee edited edge metadata.
iteratee removed rL LLVM as the repository for this revision.

Added an operand check to make sure that we only perform this optimization in the case where the mask causes the upper 32 bits to be zeroed out.

Also add a test case to verify that it fires in the correct case, and doesn't fire in the incorrect case.

One nit from me, but given I missed one thing previously I'm going to ask Hal to ack this one :)

-eric

lib/Target/PowerPC/PPCInstrInfo.cpp
1557–1561

Stylistic request: Can you move this closer to the use please?

kbarton added inline comments.Mar 7 2016, 8:56 PM
lib/Target/PowerPC/PPCInstrInfo.cpp
1559

I think you mean to use MIOpC == PPC::RLWINMo as the second part of the or statement

iteratee updated this revision to Diff 50330.Mar 10 2016, 11:55 AM
iteratee edited edge metadata.

Fix mistake caught by kbarton, and add test case to cover that mistake.

iteratee marked an inline comment as done.Mar 10 2016, 11:56 AM
iteratee added inline comments.
lib/Target/PowerPC/PPCInstrInfo.cpp
1559

I actually meant to use PPC::RLWNM.
I added a test case to cover this.

iteratee marked 2 inline comments as done.Mar 10 2016, 11:57 AM
kbarton added inline comments.Mar 10 2016, 12:15 PM
lib/Target/PowerPC/PPCInstrInfo.cpp
1559

OK, this might be a dumb question then but why not include the dot version of the instructions (RLWINMo and RLWNMo) as well?

iteratee added inline comments.Mar 10 2016, 12:43 PM
lib/Target/PowerPC/PPCInstrInfo.cpp
1559

I've added them, but maybe someone else can chime in. Is the goal of checking for those forms to allow for the collapse of multiple compares? Is this something that shows up in real code, or a belt/suspenders check?

iteratee updated this revision to Diff 50346.Mar 10 2016, 1:53 PM

Check for rotates already in dot form.

iteratee updated this revision to Diff 50347.Mar 10 2016, 1:55 PM
iteratee updated this revision to Diff 50646.Mar 14 2016, 2:14 PM
iteratee marked an inline comment as done.

Move definition closer to use.

iteratee added inline comments.Mar 14 2016, 2:15 PM
lib/Target/PowerPC/PPCInstrInfo.cpp
1557–1561

Sorry, I closed this without actually moving it closer. Really done now.

echristo accepted this revision.Mar 22 2016, 5:44 PM
echristo added a reviewer: echristo.

I'm fine here now, Kit or Hal want to comment further?

-eric

hfinkel accepted this revision.Mar 22 2016, 5:44 PM
hfinkel edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Mar 22 2016, 5:44 PM
iteratee closed this revision.Mar 23 2016, 12:57 PM