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

Jeffrey A. Law <law at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at redhat dot com
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-11-06

--- Comment #1 from Jeffrey A. Law <law at redhat dot com> ---
So the key to this testcase is the merge points.  After some slight
simplifications to the test we have the following key blocks:

;;   basic block 2, loop depth 0, count 1073741823 (estimated locally), maybe
hot
;;    prev block 0, next block 3, flags: (NEW, VISITED)
;;    pred:       ENTRY [always]  count:1073741823 (estimated locally)
(FALLTHRU,EXECUTABLE)
  if (flags_8(D) == 0)
    goto <bb 5>; [50.00%]
  else
    goto <bb 3>; [50.00%]
;;    succ:       5 [50.0% (guessed)]  count:536870912 (estimated locally)
(TRUE_VALUE,EXECUTABLE)
;;                3 [50.0% (guessed)]  count:536870912 (estimated locally)
(FALSE_VALUE,EXECUTABLE)

;;   basic block 3, loop depth 0, count 536870912 (estimated locally), maybe
hot
;;    prev block 2, next block 4, flags: (NEW, VISITED)
;;    pred:       2 [50.0% (guessed)]  count:536870912 (estimated locally)
(FALSE_VALUE,EXECUTABLE)
  if (flags_8(D) != -1)
    goto <bb 5>; [32.00%]
  else
    goto <bb 4>; [68.00%]
;;    succ:       5 [32.0% (guessed)]  count:171798688 (estimated locally)
(TRUE_VALUE,EXECUTABLE)
;;                4 [68.0% (guessed)]  count:365072224 (estimated locally)
(FALSE_VALUE,EXECUTABLE)
[ ... ]
;;   basic block 5, loop depth 0, count 708669600 (estimated locally), maybe
hot
;;    prev block 4, next block 6, flags: (NEW, VISITED)
;;    pred:       2 [50.0% (guessed)]  count:536870912 (estimated locally)
(TRUE_VALUE,EXECUTABLE)
;;                3 [32.0% (guessed)]  count:171798688 (estimated locally)
(TRUE_VALUE,EXECUTABLE)
  # orig_err_26 = PHI <errdes_10(D)(2), orig_err_9(D)(3)>
  if (in_12(D) != 0)
    goto <bb 6>; [33.00%]
  else
    goto <bb 7>; [67.00%]
;;    succ:       6 [33.0% (guessed)]  count:233860967 (estimated locally)
(TRUE_VALUE,EXECUTABLE)
;;                7 [67.0% (guessed)]  count:474808633 (estimated locally)
(FALSE_VALUE,EXECUTABLE)

;;   basic block 6, loop depth 0, count 233860966 (estimated locally), maybe
hot
;;    prev block 5, next block 7, flags: (NEW, VISITED)
;;    pred:       5 [33.0% (guessed)]  count:233860967 (estimated locally)
(TRUE_VALUE,EXECUTABLE)
  _close (in_12(D));
;;    succ:       7 [always]  count:233860966 (estimated locally)
(FALLTHRU,EXECUTABLE)

;;   basic block 7, loop depth 0, count 708669601 (estimated locally), maybe
hot
;;    prev block 6, next block 8, flags: (NEW, VISITED)
;;    pred:       6 [always]  count:233860966 (estimated locally)
(FALLTHRU,EXECUTABLE)
;;                5 [67.0% (guessed)]  count:474808633 (estimated locally)
(FALSE_VALUE,EXECUTABLE)
  if (out_14(D) != 1)
    goto <bb 8>; [48.88%]
  else
    goto <bb 9>; [51.12%]
;;    succ:       8 [48.9% (guessed)]  count:346397699 (estimated locally)
(TRUE_VALUE,EXECUTABLE)
;;                9 [51.1% (guessed)]  count:362271902 (estimated locally)
(FALSE_VALUE,EXECUTABLE)


Of particular note is that because BB2 and BB3 both reach BB5 we don't really
have any useful information about FLAGS.    The threader does know how to look
through a join point like that, but it then runs into another at BB7 at which
point it gives up.

The backwards threader probably could be made to detect this case though.  I'm
pretty sure we're not raising queries for COND_EXPRs  on the RHS of a
statement, just for GIMPLE_COND statements.  So this block:

;;   basic block 9, loop depth 0, count 708669601 (estimated locally), maybe
hot
;;    prev block 8, next block 10, flags: (NEW, VISITED)
;;    pred:       8 [always]  count:346397698 (estimated locally)
(FALLTHRU,EXECUTABLE)
;;                7 [51.1% (guessed)]  count:362271902 (estimated locally)
(FALSE_VALUE,EXECUTABLE)
  _2 = orig_err_26 != 2;
  _1 = flags_8(D) == 0;
  _3 = _2 & _1;
  if (_3 != 0)
    goto <bb 10>; [33.00%]
  else
    goto <bb 4>; [67.00%]

We don't raise a query for flags_8.  The backwards threader also doesn't know
how to imply a range from anything other than assignments.  So the conditionals
involving flags_8 aren't helpful.  This is something we're going to want to
tackle with ranger integration into the backwards threader.

SO think we keep this as an open BZ until that's addressed.

Reply via email to