This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Extend icmp bitcast to vecreduce fold to comparison with -1
ClosedPublic

Authored by nikic on Mar 21 2023, 5:25 AM.

Details

Summary

D130163 added support for folding setcc (iN (bitcast (vNi1 X))), 0, (eq|ne) to setcc (iN (zext (i1 (vecreduce_or (vNi1 X))))), 0, (eq|ne). There is a conjugate fold for comparison with -1 which uses vecreduce_and and sext instead. Proof: https://alive2.llvm.org/ce/z/Zz--xy

Diff Detail

Event Timeline

nikic created this revision.Mar 21 2023, 5:25 AM
nikic requested review of this revision.Mar 21 2023, 5:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2023, 5:25 AM
nikic added inline comments.Mar 21 2023, 6:07 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
20438

I found the formulation here is a bit roundabout -- is there a reason why we can't directly return the vecreduce result (together with a NOT, depending on predicate)?

Sorry, I've not had much review time this week but I'll take a proper look tomorrow or Friday.

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

It was just a case of not radically changing the DAG and meant not having to worry about getBooleanContents(). Simplifying setcc(ext(i1)) seems like a DAG combine independent of how the i1 is produced, which looking at the test output presumably already exists?

paulwalker-arm accepted this revision.Mar 24 2023, 6:57 AM
This revision is now accepted and ready to land.Mar 24 2023, 6:57 AM
This revision was landed with ongoing or failed builds.Mar 30 2023, 2:23 AM
This revision was automatically updated to reflect the committed changes.