aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/pr103660-2.c
blob: ce4da00a88877101e09b6b9f3d6441e9935ac6dd (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
/* PR tree-optimization/103660 */
/* { dg-do compile } */
/* { dg-options "-O1 -fgimple -fdump-tree-forwprop4-raw" } */

#define funcs(OP,n)		\
__GIMPLE()			\
int min_##n(int a, int b) {	\
  _Bool X;			\
  _Bool Y;			\
  int t;			\
  int t1;			\
  int t2;			\
  X = a < b;			\
  Y = a >= b;			\
  t1 = X ? a : 0;		\
  t2 = Y ? b : 0;		\
  t = t1 OP t2;			\
  return t;			\
}				\
__GIMPLE()			\
int f_##n(int a, int b, int c,	\
	 int d) {		\
  _Bool X;			\
  _Bool Y;			\
  int t;			\
  int t1;			\
  int t2;			\
  X = a < b;			\
  Y = a >= b;			\
  t1 = X ? c : 0;		\
  t2 = Y ? d : 0;		\
  t = t1 OP t2;			\
  return t;			\
}

funcs(^, xor)
funcs(+, plus)

/* min_xor/min_plus should produce min<a,b> */
/* f_xor/f_plus should produce (a < b) ? c : d */
/* { dg-final { scan-tree-dump-not   "bit_xor_expr, " "forwprop4" } } */
/* { dg-final { scan-tree-dump-not   "plus_expr, "    "forwprop4" } } */
/* { dg-final { scan-tree-dump-times "min_expr, "   2 "forwprop4" } } */
/* { dg-final { scan-tree-dump-times "lt_expr, "    2 "forwprop4" } } */
/* { dg-final { scan-tree-dump-times "cond_expr, "  2 "forwprop4" } } */