This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] fold 'isPositive' vector integer operations (PR26819)
ClosedPublic

Authored by spatel on Mar 2 2016, 3:38 PM.

Details

Summary

This is one of the cases shown in:
https://llvm.org/bugs/show_bug.cgi?id=26819

Shift and negate is what InstCombine prefers to produce (and I tried to make it do more of that in http://reviews.llvm.org/rL262424 ), so we should recognize that pattern as something that might come from autovectorization even if it's unlikely to be produced from C NEON intrinsics.

The patch is largely a copy/paste of the x86 equivalent:
http://reviews.llvm.org/rL262036

...so it might be worth noting as something that could be refactored into DAGCombiner so all backends can share it.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 49682.Mar 2 2016, 3:38 PM
spatel retitled this revision from to [AArch64] fold 'isPositive' vector integer operations (PR26819).
spatel updated this object.
spatel added reviewers: t.p.northover, rengolin, jmolloy.
spatel added a subscriber: llvm-commits.
t.p.northover edited edge metadata.Mar 2 2016, 4:04 PM

Thanks for working on this Sanjay, especially as it's not really your home target. Just one simplification to suggest:

lib/Target/AArch64/AArch64ISelLowering.cpp
7447 ↗(On Diff #49682)

This looks like a vestige of x86's different levels of vector support. On AArch64 all vector types are legal or none are.

So I'd suggest making this *just* the NEON check (or even an assertion), and moving the foldVectorXorShiftIntoCmp call below the isBeforeLegalizeOps check.

t.p.northover added inline comments.Mar 2 2016, 4:07 PM
lib/Target/AArch64/AArch64ISelLowering.cpp
7447 ↗(On Diff #49682)

Oh, actually you probably do need an isVectorType check to avoid doing nasty things to scalars.

spatel updated this revision to Diff 49696.Mar 2 2016, 6:12 PM
spatel edited edge metadata.

Patch updated based on Tim's suggestion: wait until after legalization, and it makes the code simpler!

t.p.northover accepted this revision.Mar 2 2016, 6:16 PM
t.p.northover edited edge metadata.

Looks good. Thanks again!

Tim.

This revision is now accepted and ready to land.Mar 2 2016, 6:16 PM
This revision was automatically updated to reflect the committed changes.