[llvm] [InstCombine] Skip redundant demanded element queries in insert chains (PR #205948)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 00:42:22 PDT 2026
================
@@ -1607,6 +1665,11 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
break;
}
case Instruction::InsertElement: {
+ auto *IE = cast<InsertElementInst>(I);
+ if (Depth == 0 && DemandedElts.isAllOnes() &&
----------------
antoniofrighetto wrote:
No strong feelings, though I think it might be slightly more elegant to have the checks grouped together inside the case:
```cpp
case Instruction::InsertElement: {
if (Depth == 0 && DemandedElts.isAllOnes() &&
VWidth > SimplifyDemandedVectorEltsDepthLimit && shouldSkip())
return nullptr;
// ...
}
```
This would let the helper to stay in sync with SimplifyDemandedVectorElts() logic, on top of leaving the threshold local to the routine. In principle, this would also benefit X86 (and downstream) target-specific intrinsics that may call InstCombine SimplifyDemandedVectorElts() on insert-chain operands (though not sure how common this is).
https://github.com/llvm/llvm-project/pull/205948
More information about the llvm-commits
mailing list