Page MenuHomePhabricator

[SVE] Add lowering for scalable vector fadd, fdiv, fmul and fsub operations.
ClosedPublic

Authored by paulwalker-arm on Jul 14 2020, 5:47 AM.

Details

Summary

Lower the operations to predicated variants. This is prep work
required for fixed length code generation but also fixes a bug
whereby these operations fail selection when "unpacked" vector
types (e.g. MVT::nxv2f32) are used.

This patch also adds the missing "unpacked" patterns for FMA.

Diff Detail

Event Timeline

paulwalker-arm created this revision.Jul 14 2020, 5:47 AM
cameron.mcinally accepted this revision.Jul 14 2020, 7:39 AM
cameron.mcinally added a subscriber: cameron.mcinally.

LGTM

Digressing a bit, but I'd like to talk about unpacked integer vector operations at the next Sync-up call. It looks like they're currently promoted, e.g. (nxv2i32->nxv2i64). I'm wondering if that's the best option, or if handling them like the unpacked FP operations is better.

This revision is now accepted and ready to land.Jul 14 2020, 7:39 AM

With this patch, we take an unpredicated operation, convert it to a predicated operation, then convert it back to an unpredicated operation? That seems a little strange at first glance, but I guess it makes the SelectionDAG more uniform.

then convert it back to an unpredicated operation

Ehh, sort of. The all-1 predicate isn't *really* all-1s. It's all-1s for the fixed-width. E.g.:

; CHECK-NEXT:    ptrue p0.d
; CHECK-NEXT:    fmla z2.s, p0/m, z0.s, z1.s

With this patch, we take an unpredicated operation, convert it to a predicated operation, then convert it back to an unpredicated operation? That seems a little strange at first glance, but I guess it makes the SelectionDAG more uniform.

The "convert it back to an unpredicated operation" part only applies to packed scalable vector types (and even then only fadd, fmul and fsub). Operations on unpacked scalable and fixed length vector (after a follow on patch) types remain predicated. I did consider restricting the lowering to only apply in those cases but figured it wasn't worth it since the _PRED patterns need to be written anyway. The same goes for any post lowering combines that prove valuable.

This revision was automatically updated to reflect the committed changes.