After https://github.com/llvm/llvm-project/pull/146350, CreateExtractElement may return a folded value and not create an ExtractElement instruction. Replace cast with dyn_cast. Note that the function returns nullptr already earlier if the extract may be constant folded. Fixes https://github.com/llvm/llvm-project/issues/147218