This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Reassociate integer extending reductions to pairwise addition.
ClosedPublic

Authored by dmgreen on Jan 25 2022, 12:40 AM.

Details

Summary

Given an (integer) vecreduce, we know the order of the inputs does not matter. We can convert UADDV(add(zext(extract_lo(x)), zext(extract_hi(x)))) into UADDV(UADDLP(x)). This can also happen through an extra add, where we transform UADDV(add(y, add(zext(extract_lo(x)), zext(extract_hi(x))))).

I've made sure the same thing happens signed cases too, which requires adding a new SADDLP node.

Diff Detail

Event Timeline

dmgreen created this revision.Jan 25 2022, 12:40 AM
dmgreen requested review of this revision.Jan 25 2022, 12:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2022, 12:40 AM
SjoerdMeijer accepted this revision.Jan 25 2022, 2:23 AM

Looks like a good change to me.

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
13207

"naming the hardest problem in computer science"?

Just a nit about the function names. Perhaps this should be performSUADDVCombine for completeness/clarity?
Then, we wouldn't need to rename performUADDVCombine to performAddUADDVCombine although the new name is probably better otherwise a 1 character letter difference would be difficult to read.

13210

Or a SADDLP if the zexts are sexts in the example above, right?

This revision is now accepted and ready to land.Jan 25 2022, 2:23 AM
This revision was landed with ongoing or failed builds.Feb 3 2022, 3:06 AM
This revision was automatically updated to reflect the committed changes.