OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [tree-ssa/] [pr19786.C] - Blame information for rev 378

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// { dg-do run }
2
/* { dg-options "-O2" } */
3
 
4
// We used to get alias grouping wrong on this one, hoisting accesses
5
// to the vector's end out of the loop.
6
 
7
#include 
8
#include 
9
 
10
struct A
11
{
12
  double unused;      // If I remove it => it works.
13
  std::vector v;
14
 
15
  A() : v(1) {}
16
};
17
 
18
inline // If not inline => it works.
19
A g()
20
{
21
  A r;
22
  r.v.resize(2);
23
  r.v[0] = 1;
24
 
25
  while (!r.v.empty() && r.v.back() == 0)
26
    r.v.pop_back();
27
 
28
  return r;
29
}
30
 
31
A f(const A &a)
32
{
33
  if (a.v.empty())  return a;
34
  if (a.v.empty())  return a;
35
 
36
  // A z = g(); return z;  // If I return like this => it works.
37
  return g();
38
}
39
 
40
int main()
41
{
42
  A a;
43
  A b;
44
  A r = f(a);
45
  assert(r.v.size() != 0);
46
 
47
  return 0;
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.