This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add `foldADCToCINC` DAG combine
ClosedPublic

Authored by Kmeakin on Apr 14 2022, 3:59 AM.

Diff Detail

Event Timeline

Kmeakin created this revision.Apr 14 2022, 3:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2022, 3:59 AM
Kmeakin requested review of this revision.Apr 14 2022, 3:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2022, 3:59 AM
paulwalker-arm added a comment.EditedApr 26 2022, 11:07 AM

It's not immediately clear to me what the advantage is to using CINC verses ADC. Sure some of the tests emit less code but for those cases it just looks like we're not making good use of xzr?

It's not immediately clear to me what the advantage is to using CINC verses ADC. Sure some of the tests emit less code but for those cases it just looks like we're not making good use of xzr?

It's true that both instructions have the same throughput and latency (on all the microarchitecures I could find the optimisation guides for), but I would argue that CSINC is a more natural/canonical way of representing this operation than ADC, which could make it easier for future optimisations to recognise it.

I'm not sure why ADC requires an extra MOV: maybe the register allocation could so with improvement?

paulwalker-arm accepted this revision.Apr 29 2022, 7:29 AM

It's not immediately clear to me what the advantage is to using CINC verses ADC. Sure some of the tests emit less code but for those cases it just looks like we're not making good use of xzr?

It's true that both instructions have the same throughput and latency (on all the microarchitecures I could find the optimisation guides for), but I would argue that CSINC is a more natural/canonical way of representing this operation than ADC, which could make it easier for future optimisations to recognise it.

Fair enough, but then in D124464 you use getNodeIfExists to see if there's an existing ADC to use in place of ADCS which depending on the ordering of combines might mean we don't find a candidate because it's been converted to CINC. That said, perhaps this isn't a realistic issue and it means we avoid the poor xzr usage issue so LGTM.

This revision is now accepted and ready to land.Apr 29 2022, 7:29 AM
This revision was landed with ongoing or failed builds.May 12 2022, 2:22 PM
This revision was automatically updated to reflect the committed changes.