[llvm] [GlobalISel] Add immediates to `LegalizerQuery` (PR #211101)

Demetrius Kanios via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 27 10:06:25 PDT 2026


================
@@ -152,20 +160,6 @@ bool WebAssemblyLegalizerInfo::legalizeCustom(
     LegalizerHelper &Helper, MachineInstr &MI,
     LostDebugLocObserver &LocObserver) const {
   switch (MI.getOpcode()) {
-  case TargetOpcode::G_SEXT_INREG: {
-    assert(MI.getOperand(2).isImm() && "Expected immediate");
-
-    // Mark only 8/16/32-bit SEXT_INREG as legal
-    auto [DstType, SrcType] = MI.getFirst2LLTs();
-    auto ExtFromWidth = MI.getOperand(2).getImm();
-
-    if (ExtFromWidth == 8 || ExtFromWidth == 16 ||
-        (DstType.getScalarSizeInBits() == 64 && ExtFromWidth == 32)) {
-      return true;
-    }
-
-    return Helper.lower(MI, 0, DstType) != LegalizerHelper::UnableToLegalize;
-  }
----------------
QuantumSegfault wrote:

Indirectly suggested by @arsenm in https://github.com/llvm/llvm-project/pull/197258#discussion_r3229483039

The context was adding the comparison predicates to LegalizerQuery (which I did in the original https://github.com/llvm/llvm-project/pull/198979), but since I was already there, this was another gap.

It's more important for FCMP, as it allows us to be able to be able to write out some new `lower`ings based on the predicate (or rather, being able to NOT lower, and choose to have some predicates be legal, and others not to control it).

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


More information about the llvm-commits mailing list