https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124901

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
> Did you check other places to schedule the pass?

I was interested to exercise opportunities, exposed by bbro pass (as
mentioned in [1]), so the natural place to put the new pass is after
bbro pass:

On x86_32, IRA zeroes %ecx, which is later copied to %eax in the
terminal basic block:

   12: NOTE_INSN_BASIC_BLOCK 3
    7: cx:SI=0
      REG_EQUAL 0
   45: pc=L36
   ...
   36: L36:
   39: NOTE_INSN_BASIC_BLOCK 7
   37: ax:SI=cx:SI
   38: use ax:SI

This sequence is reordered in bbro pass to:

   28: L28:
   12: NOTE_INSN_BASIC_BLOCK 7
   69: {cx:SI=0;clobber flags:CC;}
      REG_UNUSED flags:CC
   71: ax:SI=cx:SI
      REG_DEAD cx:SI
   72: use ax:SI
   73: NOTE_INSN_EPILOGUE_BEG
   74: bx:SI=[sp:SI++]
      REG_CFA_ADJUST_CFA sp:SI=sp:SI+0x4
      REG_CFA_RESTORE bx:SI
   75: si:SI=[sp:SI++]
      REG_CFA_ADJUST_CFA sp:SI=sp:SI+0x4
      REG_CFA_RESTORE si:SI
   76: simple_return

When - fno-reorder-blocks -fno-reorder-blocks-and-partition options are added
to compile options, the newly added pass_late_combine does nothing. So, there
indeed are new opportunities only when BB reorders blocks (duplicates paths?).

[1] https://gcc.gnu.org/pipermail/gcc-patches/2026-April/713048.html

Reply via email to