This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
predicated code motion (in lim)
- From: Evgeniya Maenkova <evgeniya dot maenkova at gmail dot com>
- To: gcc Mailing List <gcc at gcc dot gnu dot org>
- Date: Fri, 10 Oct 2014 17:44:20 +0400
- Subject: predicated code motion (in lim)
- Authentication-results: sourceware.org; auth=none
Hi,
could anyone clarify about predicated code motion in lim?
After reading a TODO in /tree-ssa-loop-im.c (see [1]) I tried several
examples, say [2]. However, in all of them the code was moved out of
the loop successfully (either by pre or by lim, as in [2]).
So my question is: what the author of this code did mean by
"predicated code motion"? (what is the TODO)
Thanks,
Evgeniya
[1]
TODO: Support for predicated code motion. I.e.
while (1)
{
if (cond)
{
a = inv;
something;
}
}
[2]
void foo(int cond, int inv)
{
int a;
int i = 0;
int j = 0;
while (j++ < 100) {
while (i++ < 2000)
{
if (j % 2)
{
a = 528*j;
printf("Hey1%d %d", a, i);//something;
}
}
}
}
lim:
;; Function foo (foo, funcdef_no=0, decl_uid=1394, cgraph_uid=0, symbol_order=0)
foo (int cond, int inv)
{
int j;
int i;
int a;
unsigned int j.0_12;
unsigned int _13;
unsigned int _18;
unsigned int _21;
<bb 2>:
goto <bb 8>;
<bb 3>:
if (_13 != 0)
goto <bb 4>;
else
goto <bb 10>;
<bb 10>:
goto <bb 5>;
<bb 4>:
printf ("Hey1%d %d", a_14, i_11);
<bb 5>:
<bb 6>:
# i_1 = PHI <i_22(8), i_11(5)>
i_11 = i_1 + 1;
if (i_1 <= 1999)
goto <bb 3>;
else
goto <bb 7>;
<bb 7>:
# i_20 = PHI <i_11(6)>
j_9 = j_23 + 1;
if (j_23 != 100)
goto <bb 11>;
else
goto <bb 9>;
<bb 11>:
<bb 8>:
# i_22 = PHI <i_20(11), 0(2)>
# j_23 = PHI <j_9(11), 1(2)>
j.0_12 = (unsigned int) j_23;
_13 = j.0_12 & 1;
_21 = (unsigned int) j_23;
_18 = _21 * 528;
a_14 = (int) _18;
goto <bb 6>;
<bb 9>:
return;
}
However, in loopinit (the optimization before lim) there was no motion
(So this was done by lim:
<bb 4>:
a_14 = j_23 * 528;
printf ("Hey1%d %d", a_14, i_11);