[InstCombine] Fix profile metadata propagation in InstCombine select folding (#179743)
Propagate profile metadata when canonicalizing SPF and drop it when
folding select instructions with logical AND/OR conditions. This fixes
profile verification failures in Transforms/InstCombine/select-and-or.ll.
1. Select Pattern Factor (SPF) Canonicalization
When canonicalizing SPF patterns (like umax/umin), InstCombine
transforms sequences like select i1 %cond,(select i1 %cmp, %x, %y), %z
into intrinsic calls wrapped in a new select. The new outer select
directly replaces the original select instruction, and its condition
(%cond) remains structurally identical. Because the condition and its
evaluated true/false semantics are unchanged, it is ok to copy the
original !prof branch weight metadata to the newly created select.
2. Logical Boolean Folds (foldSelectOfBools)
For logical boolean folds (e.g., transforming select (~a | c), a, b into
select a, (select c, true, b), false), InstCombine restructures complex
conditions into nested selects. In most cases, it is challenging to
infer what the profile weights should be for the new select
instructions. For a couple of places where should be able to infer
profile weights, I've left a TODO to follow up.