This is an archive of the discontinued LLVM Phabricator instance.

[ARM] SBFX from rsb patterns
Needs ReviewPublic

Authored by dmgreen on Sep 16 2019, 5:59 AM.

Details

Summary

Sometimes ISel will generate RSB patterns for sequences that should be transformed into sbfx, instead of the usual shifts, and we end up generating a RSB and a UBFX. This adds some extra patterns to catch the other cases. The existing sbfx patterns are selected through ARMDAGToDAGISel::tryV6T2BitfieldExtractOp, but these tablegen patterns seem to work for these cases just fine. Helps especially in the MVE predication code.

Diff Detail

Event Timeline

dmgreen created this revision.Sep 16 2019, 5:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2019, 5:59 AM

Would it make sense to try to canonicalize this to shl+ashr at the IR level?

Hello

That wouldn't help the MVE predicate case, which is what i was really after here. It is coming from a insert_vector_elt(extract_vector_elt(..)), where we generate a sign_extend_inreg, which is legalised to the rsb and the and. D67956 contains an alternative where we lower that using a LSL, SRA pair instead, which will then transform to the SBFX as desired.

I didn't see any other cases of this coming up in the tests I ran, so that alternative might be the simpler approach.