PR testsuite/86649
[official-gcc.git] / gcc / testsuite / g++.dg / tree-ssa / pr33604.C
blob668db49d1466772c5e13478c57f2ba6955d5c596
1 /* { dg-do run } */
2 /* { dg-options "-O -fdump-tree-optimized-vops" } */
4 struct Value
6   double value;
7   Value(double value_) : value (value_) {}
8   operator double() const { return value; }
9   Value& operator=(double other) { value = other; return *this; }
12 struct Ref
14   const Value& m;
15   Ref(const Value& m_) : m(m_) {}
16   operator double() const { return m; }
19 struct Diff
21   const Ref lhs, rhs;
22   Diff(const Value& lhs_, const Value& rhs_) : lhs(lhs_), rhs(rhs_) {}
23   operator double() const { return lhs - rhs; }
26 extern "C" void abort (void);
27 int main(int argc, char *argv[])
29   Value I(1), m(4);
30   for(int a = 0; a < 1000; a++)
31     m = Diff (I, m);
33   if (!(m / 4 == I))
34     abort ();
35   return 0;
38 /* Check that we propagate
39      D.2182_13 = (struct Ref *) &D.2137.lhs;
40    to
41      D.2182_13->lhs.m ={v} &I;
42    yielding
43      D.2137.lhs.m ={v} &I;
44    so that SRA can promote all locals to registers and we end up
45    referencing two virtual operands at abort () and the return
46    after optimization.  */
48 /* { dg-final { scan-tree-dump-times ".MEM_\[0-9\]*\\\(D\\\)" 2 "optimized" } } */