[PATCH] D96250: [CostModel] An extending load to illegal type is not free.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 8 03:31:16 PST 2021


sdesmalen added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:795
+        if (TLI->isLoadExtLegal(LType, ExtVT, LoadVT) &&
+            DstLT.first == SrcLT.first)
           return 0;
----------------
dmgreen wrote:
> This is that the type legalization costs are the same? I'm a little surprised that isLoadExtLegal returns true if they are not legal.
> This is that the type legalization costs are the same? 
Yes that's right, if only one of the types require splitting/scalarizing and the other does not, we can't assume the operation can be done freely as part of the the load itself, because the operation needs splitting. Looking at this condition now, perhaps it should use the legalized types instead of ExtVT and LoadVT, as in:
```if (DstLT.first == SrcLT.first && TLI->isLoadExtLegal(LType, DstLT.second, SrcLT.second)```
I'll change that.

> I'm a little surprised that isLoadExtLegal returns true if they are not legal.
`isLoadExtLegal` checks that `getLoadExtAction` returns `Legal`, where `LegalizeAction` has the following options:
```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.
};```
Splitting is not one of the options, which probably makes sense as this would already be part of the type legalization.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96250/new/

https://reviews.llvm.org/D96250



More information about the llvm-commits mailing list