[llvm] [GlobalISel] Import extract/insert subvector (PR #110287)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 08:07:56 PDT 2024
================
@@ -3163,6 +3167,58 @@ bool IRTranslator::translateInsertElement(const User &U,
return true;
}
+bool IRTranslator::translateInsertVector(const User &U,
+ MachineIRBuilder &MIRBuilder) {
+ Register Dst = getOrCreateVReg(U);
+ Register Vec = getOrCreateVReg(*U.getOperand(0));
+ Register Elt = getOrCreateVReg(*U.getOperand(1));
+
+ ConstantInt *CI = cast<ConstantInt>(U.getOperand(2));
+ unsigned PreferredVecIdxWidth = TLI->getVectorIdxTy(*DL).getSizeInBits();
+
+ // Resize Index to preferred index width.
+ if (CI->getBitWidth() != PreferredVecIdxWidth) {
+ APInt NewIdx = CI->getValue().zextOrTrunc(PreferredVecIdxWidth);
+ CI = ConstantInt::get(CI->getContext(), NewIdx);
+ }
+
+ // If it is a <1 x Ty> vector, we have to use other means.
+ if (auto *ResultType = dyn_cast<FixedVectorType>(U.getOperand(1)->getType());
+ ResultType && ResultType->getNumElements() == 1) {
+ if (auto *InputType = dyn_cast<FixedVectorType>(U.getOperand(0)->getType());
+ InputType && InputType->getNumElements() == 1) {
+ // We are inserting an illegal fixed vector into an illegal
+ // fixed vector, use the scalar as it is not a legal vector type
+ // in LLT.
+ return translateCopy(U, *U.getOperand(0), MIRBuilder);
+ }
+ if (auto *InputType =
+ dyn_cast<FixedVectorType>(U.getOperand(0)->getType())) {
+ // We are inserting an illegal fixed vector into a fixed vector, use the
----------------
tschuett wrote:
Nope. It is meant to say `InputType && InputType->getNumElements() != 1`.
https://github.com/llvm/llvm-project/pull/110287
More information about the llvm-commits
mailing list