This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/65443] Don't peel last iteration from loop in transform_to_exit_first_loop
- From: "vries at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 16 Mar 2015 17:12:28 +0000
- Subject: [Bug tree-optimization/65443] Don't peel last iteration from loop in transform_to_exit_first_loop
- Auto-submitted: auto-generated
- References: <bug-65443-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65443
--- Comment #2 from vries at gcc dot gnu.org ---
AFAIU, this is meant with the todo:
...
<bb x>:
goto <bb y>;
<bb 4>:
i_17 = (int) ivtmp_6;
_7 = (long unsigned int) i_17;
_8 = _7 * 4;
_9 = pretmp_24 + _8;
_10 = *_9;
sum_11 = _10 + sum_y;
i_12 = i_17 + 1;
i.1_3 = (unsigned int) i_12;
<bb y>:
# sum_y = PHI <1(x), sum_11(4)>
# ivtmp_y = PHI <0(x), ivtmp_6(4)>
if (ivtmp_y < _20 + 1)
goto <bb 6>;
else
goto <bb 5>;
<bb 5>:
# sum_21 = PHI <sum_11(4), sum_26(8)>
goto <bb 7>;
<bb 6>:
ivtmp_6 = ivtmp_y + 1;
goto <bb 4>;
...
So, sort of:
- Split bb 4 before the loop condition, creating bb y.
- Don't enter the loop at bb 4 as before, instead jump to before the loop
condition, to bb y (creating bb x in the process)
- For each phi in bb 4, add a corresponding phi to bb y:
- For the values for entry from bb x, use the values in the phis in bb 4 for
entry from bb 11.
- For the values for entry from bb 4, use the reaching definitions.
- increase loop bound with 1 (_20 + 1)
- simplify the phis in bb 4
- use the new phis in bb y as defs for the reachable uses
The problem with this transformation is that '_20 + 1' might overflow, that's
what the comment 'This may need some additional preconditioning in case NIT =
~0' refers to.