-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
Sometimes, a target might desire to legalize an operation by scalarizing it.
Consider a target that has a scalar ISD::ABDS for MVT::i16 but no vector version for MVT::v2i16. the current options are quite limited:
enum LegalizeAction : uint8_t {
Legal, // The target natively supports this operation.
Promote, // This operation should be executed in a larger type.
Expand, // Try to expand this to other ops, otherwise use a libcall.
LibCall, // Don't try to expand this to other ops, always use a libcall.
Custom // Use the LowerOperation hook to implement custom lowering.
};
clearly it is not Legal, Promote might not be supported, Expand returns in our case completely different ops (min, max, sub, which is 3 instructions instead of two vector instructions), LibCall is more expensive than two instructions and we are left with Custom - in a lot of cases we just point to one function downstream that basically scalarizes the operation or converts to shorter vectors (v16i16 -> v8i16 x 2). Could be great to have that upstream. opinions?
(that or just "try reduce the type, then combine immediately/call hook" instead)
or maybe consider adding a utility function that does it,