[llvm] [CodeGen] Improve `getLoadExtAction` and friends (PR #181104)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 12:00:37 PDT 2026


================
@@ -1511,49 +1512,29 @@ class LLVM_ABI TargetLoweringBase {
   /// Return how this load with extension should be treated: either it is legal,
   /// needs to be promoted to a larger size, needs to be expanded to some other
   /// code sequence, or the target has a custom expander for it.
-  LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT,
-                                  EVT MemVT) const {
-    if (ValVT.isExtended() || MemVT.isExtended()) return Expand;
-    unsigned ValI = (unsigned) ValVT.getSimpleVT().SimpleTy;
-    unsigned MemI = (unsigned) MemVT.getSimpleVT().SimpleTy;
-    assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValI < MVT::VALUETYPE_SIZE &&
-           MemI < MVT::VALUETYPE_SIZE && "Table isn't big enough!");
-    unsigned Shift = 4 * ExtType;
-    return (LegalizeAction)((LoadExtActions[ValI][MemI] >> Shift) & 0xf);
-  }
+  virtual LegalizeAction getLoadAction(EVT ValVT, EVT MemVT, Align Alignment,
+                                       MachineMemOperand::Flags MMOFlags,
+                                       unsigned AddrSpace, unsigned ExtType,
+                                       bool Atomic) const;
 
   /// Return true if the specified load with extension is legal on this target.
-  bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT) const {
-    return getLoadExtAction(ExtType, ValVT, MemVT) == Legal;
+  bool isLoadLegal(EVT ValVT, EVT MemVT, Align Alignment,
+                   MachineMemOperand::Flags MMOFlags, unsigned AddrSpace,
+                   unsigned ExtType, bool Atomic) const {
+    return getLoadAction(ValVT, MemVT, Alignment, MMOFlags, AddrSpace, ExtType,
----------------
arsenm wrote:

Right, I'm saying to move this into an isLoadExtActionImpl instead of having targets directly implement it. That's the usual pattern for weird target overrides edge case behavior 

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


More information about the llvm-commits mailing list