This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in loop invariant motion with trivial test case


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;

}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]