[llvm] [NVPTX] Generalize and extend upsizing when lowering 8/16-bit-element vector loads/stores (PR #119622)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 14:06:42 PST 2024


================
@@ -160,6 +163,76 @@ static bool Is16bitsType(MVT VT) {
           VT.SimpleTy == MVT::i16);
 }
 
+// When legalizing vector loads/stores, this function is called, which does two
+// things:
+// 1. Determines Whether the vector is something we want to custom lower,
+// std::nullopt is returned if we do not want to custom lower it.
+// 2. If we do want to handle it, returns three parameters:
+//    - unsigned int NumElts - The number of elements in the final vector
+//    - EVT EltVT - The type of the elements in the final vector
+//    - bool UpsizeElementTypes - Whether or not we are upsizing the elements of
+//    the vector
+static std::optional<std::tuple<unsigned int, EVT, bool>>
+tryGetVectorLoweringParams(EVT ValVT) {
----------------
Artem-B wrote:

`getVectorLoweringShape` ?

Nit: IMO `try` is about things that may fail. In this case nullopt is not an error, just an opinion on the input type that it's not the kind we want to process. If we were to actively do something there (e.g. construct nodes, etc), then it would fit better. I'd just skip it, and make it just `get`.

https://github.com/llvm/llvm-project/pull/119622


More information about the llvm-commits mailing list