[llvm] [InstCombine] Limit canonicalization of extractelement(cast) to constant index or same basic block. (PR #166227)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 19 02:19:44 PST 2025


================
@@ -589,8 +589,11 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
       // Bitcasts can change the number of vector elements, and they cost
       // nothing.
       if (CI->hasOneUse() && (CI->getOpcode() != Instruction::BitCast)) {
-        Value *EE = Builder.CreateExtractElement(CI->getOperand(0), Index);
-        return CastInst::Create(CI->getOpcode(), EE, EI.getType());
+        Instruction *U = cast<Instruction>(*CI->user_begin());
----------------
azwolski wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/166227


More information about the llvm-commits mailing list