This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Use record-form instruction for Less-or-Equal -1 and Greater-or-Equal 1
ClosedPublic

Authored by inouehrs on Oct 16 2017, 12:09 AM.

Details

Summary

Currently a record-form instruction is used for comparison of "greater than -1" and "less than 1" by modifying the predicate (e.g. LT 1 into LE 0) in addition to the naive case of comparison against 0.
This patch also enables emitting a record-form instruction for "less than or equal to -1" (i.e. "less than 0") and "greater than or equal to 1" (i.e. "greater than 0") to increase the optimization opportunities.

Diff Detail

Repository
rL LLVM

Event Timeline

inouehrs created this revision.Oct 16 2017, 12:09 AM
echristo edited edge metadata.Oct 16 2017, 11:49 AM

Please update the comments in both the code and the testcase to express what we're looking for and why we're looking for it. Right now if something breaks no one will know why.

inouehrs updated this revision to Diff 119259.Oct 16 2017, 11:47 PM

Comments updated/added in code and test case.

sfertile added inline comments.Oct 23 2017, 12:50 PM
lib/Target/PowerPC/PPCInstrInfo.cpp
1740–1743 ↗(On Diff #119259)

It seems to me this would be cleaner if we get rid of the 'Success' variable and convert the 2 ifs to check the opposite conditions and early return on failure.

test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll
83 ↗(On Diff #119259)

cconfirms --> confirms

inouehrs updated this revision to Diff 120013.Oct 24 2017, 2:00 AM
  • updated based on suggestions from @sfertile
  • rebased to the latest code and fixed a conflict
inouehrs marked an inline comment as done.Oct 24 2017, 2:01 AM
inouehrs added inline comments.
lib/Target/PowerPC/PPCInstrInfo.cpp
1740–1743 ↗(On Diff #119259)

is this better?

test/CodeGen/PowerPC/opt-cmp-inst-cr0-live.ll
83 ↗(On Diff #119259)

Good catch. Fixed.

Looks much better to me. Let sfertile give a final ACK since he's been in here too, but I'm happy. One inline comment :)

-eric

lib/Target/PowerPC/PPCInstrInfo.cpp
1724 ↗(On Diff #120013)

Because... :)

sfertile edited edge metadata.Oct 25 2017, 6:43 AM

Looks good to me.

nemanjai accepted this revision.Oct 25 2017, 9:37 AM

As Eric points out, perhaps mention that it would be possible to optimize even if there were multiple uses of the CR register if all the uses fell into one of the four categories, but it would be very unlikely that doing to would be profitable.

But I agree, this looks much better now.

This revision is now accepted and ready to land.Oct 25 2017, 9:37 AM
This revision was automatically updated to reflect the committed changes.
inouehrs marked an inline comment as done.