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

--- Comment #22 from Jeffrey A. Law <law at gcc dot gnu.org> ---
So looking at this after a long period away, one thing does stand out as a
potential path forward.  Specifically early jump threading.

If we look at the key blocks:

;;   basic block 4, loop depth 0, maybe hot
;;    prev block 3, next block 5, flags: (NEW, VISITED)
;;    pred:       2 (FALSE_VALUE,EXECUTABLE)
;;                3 (FALLTHRU,EXECUTABLE)
  _3 = xl_xinfo.xinfo;
  if (_3 != 0)
    goto <bb 5>; [INV]
  else
    goto <bb 6>; [INV]
;;    succ:       5 (TRUE_VALUE,EXECUTABLE)
;;                6 (FALSE_VALUE,EXECUTABLE)

;;   basic block 5, loop depth 0, maybe hot
;;    prev block 4, next block 6, flags: (NEW, VISITED)
;;    pred:       4 (TRUE_VALUE,EXECUTABLE)
  XLogRegisterData (&xl_xinfo.xinfo, 4);
;;    succ:       6 (FALLTHRU,EXECUTABLE)

;;   basic block 6, loop depth 0, maybe hot
;;    prev block 5, next block 7, flags: (NEW, VISITED)
;;    pred:       4 (FALSE_VALUE,EXECUTABLE)
;;                5 (FALLTHRU,EXECUTABLE)
  _4 = xl_xinfo.xinfo;
  _5 = _4 & 16;
  if (_5 != 0)
    goto <bb 7>; [INV]
  else
    goto <bb 8>; [INV]
;;    succ:       7 (TRUE_VALUE,EXECUTABLE)
;;                8 (FALSE_VALUE,EXECUTABLE)

;;   basic block 7, loop depth 0, maybe hot
;;    prev block 6, next block 8, flags: (NEW, VISITED)
;;    pred:       6 (TRUE_VALUE,EXECUTABLE)
  _6 = strlen (twophase_gid_19(D));
  _7 = _6 + 1;
  _8 = (int) _7;
  XLogRegisterData (twophase_gid_19(D), _8);
;;    succ:       8 (FALLTHRU,EXECUTABLE)

We could thread 4->6 so that it reaches 8 instead during early jump threading. 
Then we would also need to improve ccp2 to dectect the obviously unnecessary
conditional and the end of bb4.  The combination of those two I think would
clean things up enough to address this specific problem.

Reply via email to