1 /* { dg-do compile { target { ! ia32 } } } */
2 /* { dg-options "-O2 -mx32 -maddress-mode=long" } */
3 /* { dg-skip-if "different ABI" { x86_64-*-mingw* } } */
4 
5 typedef union tree_node *tree;
6 typedef const union tree_node *const_tree;
7 typedef struct {
8   unsigned long long low;
9   long long high;
10 } double_int;
11 struct real_value {
12 };
13 struct real_format {
14   int has_signed_zero;
15 };
16 extern const struct real_format *   real_format_for_mode[];
17 extern int real_isnegzero (const struct real_value *);
18 enum tree_code { REAL_CST, SSA_NAME };
19 struct tree_base {
20   enum tree_code code : 16;
21   union {
22     unsigned int version;
23   }
24   u;
25 };
26 extern void tree_check_failed (const_tree, const char *, int, const char *,           ...) __attribute__ ((__noreturn__));
27 union tree_node {
28   struct tree_base base;
29 };
tree_check(tree __t,const char * __f,int __l,const char * __g,enum tree_code __c)30 inline tree tree_check (tree __t, const char *__f, int __l, const char *__g, enum tree_code __c) {
31   if (((enum tree_code) (__t)->base.code) != __c)
32     tree_check_failed (__t, __f, __l, __g, __c, 0);
33   return __t;
34 }
35 struct prop_value_d {
36   int lattice_val;
37   tree value;
38   double_int mask;
39 };
40 typedef struct prop_value_d prop_value_t;
41 static prop_value_t *const_val;
42 static void canonicalize_float_value (prop_value_t *);
43 typedef void (*ssa_prop_visit_stmt_fn) (prop_value_t);
44 typedef void (*ssa_prop_visit_phi_fn) (void);
45 typedef void (*ssa_prop_fold_stmt_fn) (void *gsi);
46 typedef void (*ssa_prop_get_value_fn) ( prop_value_t *val);
47 void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
48 int substitute_and_fold (ssa_prop_get_value_fn, ssa_prop_fold_stmt_fn);
49 void ccp_fold_stmt (void *);
get_constant_value(prop_value_t * val)50 static void get_constant_value (prop_value_t *val) {
51   canonicalize_float_value (val);
52 }
canonicalize_float_value(prop_value_t * val)53 static void canonicalize_float_value (prop_value_t *val) {
54   int mode;
55   struct real_value d;
56   if (val->lattice_val != 1
57       || ((enum tree_code) (val->value)->base.code) != REAL_CST)
58     return;
59   mode = val->lattice_val;
60   if (real_format_for_mode[mode]->has_signed_zero && real_isnegzero (&d))
61     ccp_fold_stmt (0);
62 }
set_lattice_value(tree var,prop_value_t new_val)63 static void set_lattice_value (tree var, prop_value_t new_val) {
64   prop_value_t *old_val = &const_val[(tree_check ((var), "",
65 						  0, "",
66 						  (SSA_NAME)))->base.u.version];
67   canonicalize_float_value (&new_val);
68   canonicalize_float_value (old_val);
69 }
ccp_visit_phi_node(void)70 static void ccp_visit_phi_node (void) {
71   prop_value_t new_val;
72   set_lattice_value (0, new_val);
73 }
ccp_visit_stmt(prop_value_t v)74 static void ccp_visit_stmt (prop_value_t v) {
75   set_lattice_value (0, v);
76 }
do_ssa_ccp(void)77 unsigned int do_ssa_ccp (void) {
78   ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node);
79   substitute_and_fold (get_constant_value, ccp_fold_stmt);
80   return 0;
81 }
82