Could we enhance the ifcombine pass?

ywgrit yw987194828@gmail.com
Fri Jul 18 12:54:15 GMT 2025


For now, if combine pass can combine the simple nested comparison branches,
e.g.
if (a != b)
  if (c == d)
These cond bbs must have only the conditional, which is too harsh.

We often meet code like this:
if (a != b)
  if (m[index] == k[index])
m and c are arrays, so the 2nd branch belongs to a bb that has mem_ref
gimples and these stmts could trap. So these stmts won't pass the
bb_no_side_effects_p check, the branches can't be merged and performance
gains are lost, what are the way to merge these branches bb?
I think there are extremely many such nested branches and probably the
prediction accuracy of such nested branches is not very high, so doing
branch merging will  result in high performance gain.


More information about the Gcc mailing list