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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-04-05
            Summary|ifconvert if(cond) ++count; |ifconvert if(cond) ++count;
                   |to count += cond;           |to count += cond; fails
                   |                            |because of mergephi and
                   |                            |failed loop header copying
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think the issue is that the increment of n is in the latch block and that
we didn't properly copy the loop header:

;; Function int f0() (_Z2f0v, funcdef_no=3715, decl_uid=71164, cgraph_uid=957,
symbol_order=963)

fix_loop_structure: fixing up loops for function
Disambiguating loop 1 with multiple latches
Merged latch edges of loop 1

It is mergephi that merges the header and latch PHIs:

  <bb 3>:
  # n_1 = PHI <0(2), n_2(6)>
  # i_3 = PHI <1(2), _22(6)>
  _8 = (long unsigned int) i_3;
  _33 = MEM[(int * *)&v];
...
  if (_29 != 0)
    goto <bb 5>;
  else
    goto <bb 6>;

  <bb 5>:
  n_30 = n_1 + 1;

  <bb 6>:
  # n_2 = PHI <n_1(4), n_30(5)>
  goto <bb 3>;

to

  <bb 3>:
  # n_1 = PHI <0(2), n_30(5), n_1(4)>
  # i_3 = PHI <1(2), _22(5), _22(4)>
  _8 = (long unsigned int) i_3;
...
  if (_29 != 0)
    goto <bb 5>;
  else
    goto <bb 3>;

  <bb 5>:
  n_30 = n_1 + 1;
  goto <bb 3>;

creating multiple latches.  We still fail to copy loop headers properly
for -fdisable-tree-mergephi[123] though.

So the issues are elsewhere and tree ifcvt should handle this fine
already.

Reply via email to