[llvm] [CVP][LVI] Add support for InsertElementInst in LVI (PR #99368)
Rajat Bajpai via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 23:19:56 PDT 2024
================
@@ -1038,6 +1043,37 @@ LazyValueInfoImpl::solveBlockValueIntrinsic(IntrinsicInst *II, BasicBlock *BB) {
MetadataVal);
}
+std::optional<ValueLatticeElement>
+LazyValueInfoImpl::solveBlockValueInsertElement(InsertElementInst *IEI,
+ BasicBlock *BB) {
+ std::optional<ValueLatticeElement> OptEltVal =
+ getBlockValue(IEI->getOperand(1), BB, IEI);
+ if (!OptEltVal)
+ return std::nullopt;
+ ValueLatticeElement &EltVal = *OptEltVal;
+
+ if (auto *CV = dyn_cast<ConstantVector>(IEI->getOperand(0))) {
+ // Must be vector of integers. Merge these elements to create
+ // the range.
+ for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) {
+ Constant *Elem = CV->getAggregateElement(i);
+ if (isa<PoisonValue>(Elem))
+ continue;
+ std::optional<ConstantRange> CR = getRangeFor(Elem, IEI, BB);
+ if (!CR)
+ return std::nullopt;
+ EltVal.mergeIn(ValueLatticeElement::getRange(*CR));
+ }
+ } else if (!isa<PoisonValue>(IEI->getOperand(0))) {
+ std::optional<ValueLatticeElement> OptVecResult =
+ solveBlockValueImpl(IEI->getOperand(0), BB);
+ if (!OptVecResult)
+ return std::nullopt;
+ EltVal.mergeIn(*OptVecResult);
+ }
+ return EltVal;
----------------
rajatbajpai wrote:
I tried `getBlockValue` initially but test2 fails without `ConstantVector` logic. Maybe `getBlockValue` needs handling for `ConstantVector`?
https://github.com/llvm/llvm-project/pull/99368
More information about the llvm-commits
mailing list