[llvm] [InstCombine] Skip redundant demanded element queries in insert chains (PR #205948)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 30 01:47:09 PDT 2026
================
@@ -1607,6 +1662,12 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
break;
}
case Instruction::InsertElement: {
+ auto *IE = cast<InsertElementInst>(I);
+ if (Depth == 0 && DemandedElts.isAllOnes() &&
+ VWidth > SimplifyDemandedVectorEltsDepthLimit &&
+ canSkipDemandedEltsInInsertChain(*IE, VWidth))
+ return nullptr;
----------------
antoniofrighetto wrote:
Could the use-site look as follows? This actually confines the threshold to the call site and keeps the helper independent of the global.
```cpp
case Instruction::InsertElement: {
unsigned DepthLimit = SimplifyDemandedVectorEltsDepthLimit;
auto *IE = cast<InsertElementInst>(I);
if (Depth == 0 && DemandedElts.isAllOnes() &&
VWidth > DepthLimit &&
canSkipDemandedEltsInInsertChain(*IE, VWidth, DepthLimit))
return nullptr;
```
Nit: I'd also leave a one-line comment before the check explaining the ratio.
https://github.com/llvm/llvm-project/pull/205948
More information about the llvm-commits
mailing list