[llvm] [X86] Fix bool vector extension for non-power-of-2 sizes (PR #228921)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 01:56:00 PDT 2026
================
@@ -48649,6 +48649,24 @@ static SDValue combineToExtendBoolVectorInReg(
unsigned NumElts = VT.getVectorNumElements();
assert(NumElts == SclVT.getSizeInBits() && "Unexpected bool vector size");
+ // If the scalar integer doesn't split evenly into the vector element size
+ // (e.g. i12 -> v12i8), extend it to the next multiple, extend that and
+ // extract the original elements.
+ if (NumElts > EltSizeInBits && (NumElts % EltSizeInBits) != 0) {
+ unsigned WideNumElts = alignTo(NumElts, EltSizeInBits);
+ LLVMContext &Ctx = *DAG.getContext();
+ EVT WideVT = EVT::getVectorVT(Ctx, SVT, WideNumElts);
+ EVT WideBoolVT = EVT::getVectorVT(Ctx, MVT::i1, WideNumElts);
+ SDValue WideN0 = DAG.getBitcast(
+ WideBoolVT, DAG.getNode(ISD::ANY_EXTEND, DL,
+ EVT::getIntegerVT(Ctx, WideNumElts), N00));
+ if (SDValue Ext = combineToExtendBoolVectorInReg(Opcode, DL, WideVT, WideN0,
+ DAG, DCI, Subtarget))
+ return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Ext,
----------------
RKSimon wrote:
```suggestion
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Ext, 0);
```
https://github.com/llvm/llvm-project/pull/228921
More information about the llvm-commits
mailing list