Issue 171909
Summary [SDAG] Scalarization as an option in `LegalizeAction`
Labels new issue
Assignees
Reporter natanelh-mobileye
    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?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to