https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100173
--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> --- > but yes, cselim will also sink the first store, moving it across the Can we also sink loads? assign pointer to another temp pointer in both if and else bb, and then load val from this temp pointer. those assignments that in if and else branch would be finially transformed to conditional mov. performance can benifit 100% with below change. for (i = 0; i < (1<<5)/2; i++) { esMetricIn = *pBranchMetric++; esMetric1 = pIn1->m_esPathMetric - esMetricIn; esMetric2 = pIn2->m_esPathMetric + esMetricIn; e_s16 *t1p = (esMetric1 >= esMetric2) ? &(pIn1->m_esState) : &(pIn2->m_esState); e_s16 t1 = (esMetric1 >= esMetric2) ? esMetric1 : esMetric2; pOut->m_esPathMetric = t1; pOut->m_esState = *t1p << 1; pOut++; esMetric1 = pIn1->m_esPathMetric + esMetricIn; esMetric2 = pIn2->m_esPathMetric - esMetricIn; e_s16 *t2p = (esMetric1 >= esMetric2) ? &(pIn1->m_esState) : &(pIn2->m_esState); e_s16 t2 = (esMetric1 >= esMetric2) ? esMetric1 : esMetric2; pOut->m_esPathMetric = t2; pOut->m_esState = *t2p << 1; pOut++; pIn1++; pIn2++; }