[llvm] [GlobalISel] Add `widenScalarFor()` function (PR #187731)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 20 09:23:55 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-globalisel

Author: Igor Wodiany (IgWod)

<details>
<summary>Changes</summary>

The function is mentioned in `Legalizer.rst` but has been missing. This also fixes the asymetry between `narrowScalarXXX()` that has both `narrowScalarFor()` and `narrowScalarIf()`, and `widenScalarXXX()` that only had `widenScalarIf()`.

---
Full diff: https://github.com/llvm/llvm-project/pull/187731.diff


1 Files Affected:

- (modified) llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h (+8) 


``````````diff
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
index 498594f40e694..9afccf86576f2 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -840,6 +840,14 @@ class LegalizeRuleSet {
     markAllIdxsAsCovered();
     return actionIf(LegalizeAction::WidenScalar, Predicate, Mutation);
   }
+  /// Widen the scalar, specified in mutation, when type indexes 0 and 1 is any
+  /// type pair in the given list.
+  LegalizeRuleSet &
+  widenScalarFor(std::initializer_list<std::pair<LLT, LLT>> Types,
+                 LegalizeMutation Mutation) {
+    return actionFor(LegalizeAction::WidenScalar, Types, Mutation);
+  }
+
   /// Narrow the scalar to the one selected by the mutation if the predicate is
   /// true.
   LegalizeRuleSet &narrowScalarIf(LegalityPredicate Predicate,

``````````

</details>


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


More information about the llvm-commits mailing list