Bug in loop invariant motion with trivial test case
Richard Kenner
kenner@vlsi1.ultra.nyu.edu
Thu Aug 12 11:01:00 GMT 2004
This is based on ACATS test ca11012.
Consider:
struct foo {int a; int b;};
extern struct foo sub2 (struct foo, struct foo);
struct foo
sub1 (struct foo a)
{
struct foo result = {0, 0};
int i;
for (i = 0; i < 3; i++)
result = sub2 (result, a);
return result;
}
Look at the .vars file and notice that each call to sub2 is passed the
same operands, not the one obtained by calling the function the
previous time:
sub1 (a)
{
struct foo lsm_tmp.2;
struct foo lsm_tmp.1;
int i;
struct foo result;
struct foo T.0;
<bb 0>:
result.a = 0;
result.b = 0;
lsm_tmp.1 = result;
i = 0;
<L0>:;
lsm_tmp.2 = sub2 (result, a);
i = i + 1;
if (i <= 2) goto <L0>; else goto <L7>;
<L7>:;
result = lsm_tmp.1;
T.0 = result;
return T.0;
}
More information about the Gcc
mailing list