[llvm] [ValueTracking] Support scalable vectors for ExtractElement in computeKnownFPClass. (PR #143051)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 5 17:06:05 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Craig Topper (topperc)
<details>
<summary>Changes</summary>
We can support scalable vectors by setting the demanded mask to APInt(1, 1) to demand the whole vector.
---
Full diff: https://github.com/llvm/llvm-project/pull/143051.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/ValueTracking.cpp (+7-7)
``````````diff
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 0a460786d00ea..30357c170f3d7 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -5604,19 +5604,19 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
// Look through extract element. If the index is non-constant or
// out-of-range demand all elements, otherwise just the extracted element.
const Value *Vec = Op->getOperand(0);
- const Value *Idx = Op->getOperand(1);
- auto *CIdx = dyn_cast<ConstantInt>(Idx);
+ APInt DemandedVecElts;
if (auto *VecTy = dyn_cast<FixedVectorType>(Vec->getType())) {
unsigned NumElts = VecTy->getNumElements();
- APInt DemandedVecElts = APInt::getAllOnes(NumElts);
+ DemandedVecElts = APInt::getAllOnes(NumElts);
+ auto *CIdx = dyn_cast<ConstantInt>(Op->getOperand(1));
if (CIdx && CIdx->getValue().ult(NumElts))
DemandedVecElts = APInt::getOneBitSet(NumElts, CIdx->getZExtValue());
- return computeKnownFPClass(Vec, DemandedVecElts, InterestedClasses, Known,
- Q, Depth + 1);
- }
+ } else
+ DemandedVecElts = APInt(1, 1);
- break;
+ return computeKnownFPClass(Vec, DemandedVecElts, InterestedClasses, Known,
+ Q, Depth + 1);
}
case Instruction::InsertElement: {
if (isa<ScalableVectorType>(Op->getType()))
``````````
</details>
https://github.com/llvm/llvm-project/pull/143051
More information about the llvm-commits
mailing list