This is an archive of the discontinued LLVM Phabricator instance.

[SPARC] Lower SELECT_CC to MOVr on 64-bit target whenever possible
ClosedPublic

Authored by koakuma on Nov 29 2022, 7:04 AM.

Details

Summary

On 64-bit target, when doing i64 SELECT_CC where one of the comparison operands is a constant zero, try to fold the compare and MOVcc into a MOVr instruction.

For all integers, EQ and NE comparison are available, additionally for signed integers, GT, GE, LT, and LE is also available.

Diff Detail

Event Timeline

koakuma created this revision.Nov 29 2022, 7:04 AM
koakuma requested review of this revision.Nov 29 2022, 7:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 7:04 AM
arsenm requested changes to this revision.Nov 29 2022, 12:52 PM
arsenm added inline comments.
llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.cpp
212–213

Can't say I understand these magic numbers but they seem to be following a pattern

llvm/lib/Target/Sparc/Sparc.h
98

Could add _BEGIN/ _END entries for these to avoid the hardcoded numbers other places

llvm/lib/Target/Sparc/SparcISelLowering.cpp
1479

ISD::isUnsignedIntSetCC already exists

1486

Lowercase

This revision now requires changes to proceed.Nov 29 2022, 12:52 PM
koakuma updated this revision to Diff 478785.Nov 29 2022, 7:26 PM

Address review comments and remove redundant includes.

arsenm added inline comments.Dec 5 2022, 3:06 PM
llvm/lib/Target/Sparc/SparcISelLowering.cpp
2649–2651

can use isNullConstant

llvm/lib/Target/Sparc/SparcInstrAliases.td
62–88

Could use assembler tests

koakuma updated this revision to Diff 480302.Dec 5 2022, 6:08 PM
  • Address review comments
  • Add assembly tests for MOVRri, FMOVRD, and FMOVRQ instruction templates
arsenm accepted this revision.Dec 6 2022, 8:21 PM
This revision is now accepted and ready to land.Dec 6 2022, 8:21 PM
This revision was landed with ongoing or failed builds.Dec 7 2022, 12:35 PM
This revision was automatically updated to reflect the committed changes.
ro added a subscriber: ro.Dec 21 2022, 1:36 PM

This patch broke Solaris/sparcv9 bootstrap. Details in Issue #59646.

In D138922#4011537, @ro wrote:

This patch broke Solaris/sparcv9 bootstrap. Details in Issue #59646.

I've posted a patch at D140515, can you please try it?