[llvm] sketch idea of getConstantBuildVector (PR #180074)

via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 15 02:29:26 PST 2026


================
@@ -905,6 +905,25 @@ class SelectionDAG {
     return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
   }
 
+  /// Return a BUILD_VECTOR of constants from an array of APInt values.
+  ///
+  /// \p VT must be a fixed-width integer vector type. \p Ops contains the
+  /// constant value for each element (sized to VT's scalar size in bits).
+  /// Bits set in \p UndefElts indicate elements that should be UNDEF.
+  ///
+  /// When NewNodesMustHaveLegalTypes is true (i.e., after type legalization),
+  /// the element constants are created using a promoted legal type, relying
+  /// on BUILD_VECTOR's implicit truncation semantics. This avoids creating
+  /// nodes with illegal scalar types that would otherwise trigger assertions.
+  LLVM_ABI SDValue getConstantBuildVector(EVT VT, const SDLoc &DL,
+                                          ArrayRef<APInt> Ops,
----------------
natanelh-mobileye wrote:

Suggestion: add overload for before legalization, where VT would be the same as Ops[0].getValueType()

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


More information about the llvm-commits mailing list