[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
Mon Nov 3 12:32:19 PST 2025


azwolski wrote:

In `@test_poison_branch`, the `cast` and `extractelement` are placed in different basic blocks. However, the canonicalization still occurs because `tryToSinkInstruction` in `InstCombine/InstructionCombining.cpp` sinks the cast into the `false` block:

BB after sinking:
```llvm
false:                                            ; preds = %entry
  %vi = fptosi <4 x float> %in to <4 x i32>
  %elem = extractelement <4 x i32> %vi, i32 %i
  call void @use(i32 %elem)
  br label %done
 ```

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


More information about the llvm-commits mailing list