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