fixed fxch emitter
[libfirm] / ir / be / ia32 / ia32_optimize.c
index b3a5687..beb96c9 100644 (file)
@@ -407,6 +407,32 @@ void ia32_peephole_optimization(ir_node *irn, void *env) {
        else if (is_ia32_CondJmp(irn)) {
                ia32_optimize_CondJmp(irn, env);
        }
+#if 0
+       else if (be_is_IncSP(irn)) {
+               ir_node *prev = sched_prev(irn);
+
+               if (be_is_IncSP(prev)) {
+                       /* two scheduled IncSP one-after-one, kill the first one */
+                       unsigned       prev_offs = be_get_IncSP_offset(prev);
+                       be_stack_dir_t prev_dir  = be_get_IncSP_direction(prev);
+                       unsigned       curr_offs = be_get_IncSP_offset(irn);
+                       be_stack_dir_t curr_dir  = be_get_IncSP_direction(irn);
+
+                       int new_ofs = prev_offs * (prev_dir == be_stack_dir_expand ? -1 : +1) +
+                                     curr_offs * (curr_dir == be_stack_dir_expand ? -1 : +1);
+
+                       if (new_ofs < 0) {
+                               new_ofs  = -new_ofs;
+                               curr_dir = be_stack_dir_expand;
+                       }
+                       else
+                               curr_dir = be_stack_dir_shrink;
+                       be_set_IncSP_offset(prev, 0);
+                       be_set_IncSP_offset(irn, (unsigned)new_ofs);
+                       be_set_IncSP_direction(irn, curr_dir);
+               }
+       }
+#endif
 }