[llvm] InstCombine: Fold bitcast of vector with constant to scalar (PR #179042)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 2 03:47:41 PST 2026


nikic wrote:

> > Your tests convert a vector select into a scalar select, which seems reasonable. But what about the case where this ends up converting a scalar select into a vector select?
> 
> It's not producing vector select, it's producing select of vector type.

Yes, that's what I meant. Replacing a scalar select with a select of vector type may be a significant pessimization, e.g. on x86 the former will use cmov and the latter will use a branch. See https://llvm.godbolt.org/z/WodKcbrbe for an example.

If you want to convert scalar to more expensive vector selects we need to have undo-transforms in the backend in place.

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


More information about the llvm-commits mailing list