This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Fold away unnecessary CSET/CMPZ
ClosedPublic

Authored by dmgreen on Nov 16 2021, 10:12 AM.

Details

Summary

Codegen from expanded vector operations can end up with unnecessary CMPZ/CSINC, of the form:

CSXYZ A, B, C1 (CMPZ (CSINC 0, 0, C2, D), 0)

These can be converted to remove the CMPZ and CSINC, depending on the condition.

if C1==NE -> CSXYZ A, B, C2, D
if C1==EQ -> CSXYZ A, B, NOT(C2), D

Diff Detail

Event Timeline

dmgreen created this revision.Nov 16 2021, 10:12 AM
dmgreen requested review of this revision.Nov 16 2021, 10:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 16 2021, 10:12 AM
dmgreen updated this revision to Diff 388042.Nov 17 2021, 11:37 PM

I had uploaded the wrong version of the patch (but mostly the correct tests). This hopefully gets that right again.

First a high-level, perhaps silly question: could we do this simplification earlier? If this is the result of expanding vector operations, could we this where the expansion happens? Or is this the best place to do this?

First a high-level, perhaps silly question: could we do this simplification earlier? If this is the result of expanding vector operations, could we this where the expansion happens? Or is this the best place to do this?

I think this is the most general place for it. It captures several places this can come from.

I have some other related CSINC/CSINV patterns to upload too, they are just tablegen patterns. In the process of creating them I was wondering if we should be removing the CSINC/CSINV/CSNEG node types and use CMOV for everything, selecting from them. That would be a larger job though, and would likely need something like this anyway.

SjoerdMeijer accepted this revision.Nov 22 2021, 2:58 AM

Okidoki, cheers, LGTM

llvm/lib/Target/ARM/ARMISelLowering.cpp
14547

Nit: N -> Cmp

This revision is now accepted and ready to land.Nov 22 2021, 2:58 AM
This revision was landed with ongoing or failed builds.Nov 27 2021, 11:07 AM
This revision was automatically updated to reflect the committed changes.