OSDN Git Service

PR tree-optimization/53239
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / opt / vrp3.C
1 // PR tree-optimization/53239
2 // { dg-do run }
3 // { dg-options "-O2" }
4 // { dg-additional-sources "vrp3-aux.cc" }
5
6 #include "vrp3.h"
7
8 struct M
9 {
10   M (R m);
11   R val;
12   static int compare (M const &, M const &);
13 };
14
15 inline M const &
16 min (M const & t1, M const & t2)
17 {
18   return R::compare (t1.val, t2.val) < 0 ? t1 : t2;
19 }
20
21 M::M (R m)
22 {
23   val = m;
24 }
25
26 M
27 test (M *x)
28 {
29   M n (R (0, 0));
30
31   for (int i = 0; i < 2; i++)
32     {
33       M p = x[i];
34       n = min (n, p);
35     }
36
37   if (n.val.r2 != 2 || n.val.r1 != 1)
38     __builtin_abort ();
39   return n;
40 }
41
42 int
43 main ()
44 {
45   M x[2] = { M (R (1, 2)), M (R (1, 1)) };
46   test (x);
47 }