This is an archive of the discontinued LLVM Phabricator instance.

[VectorLegalizer] Expansion of CTLZ using CTPOP when possible
ClosedPublic

Authored by RKSimon on Oct 24 2016, 9:01 AM.

Details

Summary

This patch avoids scalarization of CTLZ by instead expanding to use CTPOP (from "Hacker's Delight") when the necessary operations are available.

This also adds the necessary cost models for X86 SSE2 targets (the main beneficiary) to ensure vectorization only happens when its useful.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 75592.Oct 24 2016, 9:01 AM
RKSimon retitled this revision from to [VectorLegalizer] Expansion of CTLZ using CTPOP when possible.
RKSimon updated this object.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
craig.topper added inline comments.Oct 28 2016, 9:59 PM
lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
1070–1071

Isn't this ternary operator unneeded now?

RKSimon updated this revision to Diff 76300.Oct 29 2016, 6:34 AM

Simplified ExpandCTTZ_ZERO_UNDEF since we know its ISD::CTTZ_ZERO_UNDEF - thanks Craig

craig.topper added inline comments.Nov 4 2016, 12:52 PM
lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
1056

Do we need to protect non-power of 2 bit widths here? I think the scalar equivalent does protect that.

RKSimon updated this revision to Diff 77092.Nov 7 2016, 1:35 PM

Limit vector expansion to power-of-2 sized elements

craig.topper accepted this revision.Nov 7 2016, 9:39 PM
craig.topper edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 7 2016, 9:39 PM
This revision was automatically updated to reflect the committed changes.