[llvm] sketch idea of getConstantBuildVector (PR #180074)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 11 02:31:09 PST 2026
================
@@ -2194,6 +2194,46 @@ SDValue SelectionDAG::getMaskFromElementCount(const SDLoc &DL, EVT DataVT,
getConstant(0, DL, IdxVT), getElementCount(DL, IdxVT, EC));
}
+SDValue SelectionDAG::getConstantBuildVector(EVT VT, const SDLoc &DL,
+ ArrayRef<APInt> Ops,
+ const APInt &UndefElts) {
+ assert(VT.isFixedLengthVector() && "Expected fixed-length vector type");
+ assert(VT.getVectorNumElements() == Ops.size() &&
+ "Mismatch between VT element count and Ops size");
+ assert(UndefElts.getBitWidth() == Ops.size() &&
+ "Mismatch between UndefElts width and Ops size");
+ unsigned NumElts = VT.getVectorNumElements();
+ EVT EltVT = VT.getVectorElementType();
+ assert(EltVT.isInteger() && "Expected integer element type");
+ // Determine the type to use for the constant elements. After type
+ // legalization, the original scalar element type may be illegal (e.g., i32
+ // on LoongArch64 where only i64 is legal). In that case, we promote to a
+ // legal type and rely on BUILD_VECTOR's implicit truncation.
+ EVT ConstantVT = EltVT;
+ if (NewNodesMustHaveLegalTypes) {
+ auto Action = TLI->getTypeAction(*getContext(), EltVT);
+ if (Action == TargetLowering::TypePromoteInteger)
+ ConstantVT = TLI->getTypeToTransformTo(*getContext(), EltVT);
+ }
+ SmallVector<SDValue, 16> BVOps(NumElts);
+ for (unsigned i = 0; i < NumElts; ++i) {
----------------
RKSimon wrote:
(style)
```suggestion
for (unsigned I = 0; I != NumElts; ++I) {
```
https://github.com/llvm/llvm-project/pull/180074
More information about the llvm-commits
mailing list