aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/opt/vrp3.C
blob: 90162bfe1c009c9272f4e36b39f0c8ecfa6740a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// PR tree-optimization/53239
// { dg-do run }
// { dg-options "-O2" }
// { dg-additional-sources "vrp3-aux.cc" }

#include "vrp3.h"

struct M
{
  M (R m);
  R val;
  static int compare (M const &, M const &);
};

inline M const &
min (M const & t1, M const & t2)
{
  return R::compare (t1.val, t2.val) < 0 ? t1 : t2;
}

M::M (R m)
{
  val = m;
}

M
test (M *x)
{
  M n (R (0, 0));

  for (int i = 0; i < 2; i++)
    {
      M p = x[i];
      n = min (n, p);
    }

  if (n.val.r2 != 2 || n.val.r1 != 1)
    __builtin_abort ();
  return n;
}

int
main ()
{
  M x[2] = { M (R (1, 2)), M (R (1, 1)) };
  test (x);
}