]> gcc.gnu.org Git - gcc.git/commitdiff
ifcvt.c (noce_try_store_flag, [...]): Insert new code before JUMP, not EARLIEST.
authorRichard Henderson <rth@gcc.gnu.org>
Fri, 3 May 2002 20:34:31 +0000 (13:34 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 3 May 2002 20:34:31 +0000 (13:34 -0700)
        * ifcvt.c (noce_try_store_flag, noce_try_store_flag_constants,
        noce_try_store_flag_inc, noce_try_store_flag_mask, noce_try_cmove,
        noce_try_cmove_arith, noce_try_minmax, noce_try_abs): Insert new
        code before JUMP, not EARLIEST.

From-SVN: r53123

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/gcc.c-torture/execute/20020503-1.c [new file with mode: 0644]

index 33029bb6b15cdce550fc895c8d13344f088a8d5e..6e53aa4d951bd1e1b76ca9f726c59bec26b795f5 100644 (file)
@@ -1,3 +1,11 @@
+2002-05-03  Richard Henderson  <rth@redhat.com>
+
+       PR opt/6534
+       * ifcvt.c (noce_try_store_flag, noce_try_store_flag_constants,
+       noce_try_store_flag_inc, noce_try_store_flag_mask, noce_try_cmove,
+       noce_try_cmove_arith, noce_try_minmax, noce_try_abs): Insert new
+       code before JUMP, not EARLIEST.
+
 2002-05-03  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * c-format.c (check_format_info_main): Don't check for presence of
@@ -147,10 +155,10 @@ Thu May  2 19:50:04 CEST 2002  Jan Hubicka  <jh@suse.cz>
 
 2002-05-02  Aldy Hernandez  <aldyh@redhat.com>
 
-        * gcc.dg/altivec-8.c: New.
+       * gcc.dg/altivec-8.c: New.
 
-        * config/rs6000/rs6000.c (rs6000_legitimate_address): Disallow
-        PRE_INC and PRE_DEC for altivec modes.
+       * config/rs6000/rs6000.c (rs6000_legitimate_address): Disallow
+       PRE_INC and PRE_DEC for altivec modes.
 
 2002-05-01  Bruce Korb  <bkorb@gnu.org>
 
index f46a6cf7cc151e3c63b4e6fb186530a6f5936e7d..e8c2b5f89b94a7eb46b224f6419c884c364ffed0 100644 (file)
@@ -620,7 +620,7 @@ noce_try_store_flag (if_info)
 
       seq = get_insns ();
       end_sequence ();
-      emit_insns_before (seq, if_info->cond_earliest);
+      emit_insns_before (seq, if_info->jump);
 
       return TRUE;
     }
@@ -755,7 +755,7 @@ noce_try_store_flag_constants (if_info)
       if (seq_contains_jump (seq))
        return FALSE;
 
-      emit_insns_before (seq, if_info->cond_earliest);
+      emit_insns_before (seq, if_info->jump);
 
       return TRUE;
     }
@@ -815,7 +815,7 @@ noce_try_store_flag_inc (if_info)
          if (seq_contains_jump (seq))
            return FALSE;
 
-         emit_insns_before (seq, if_info->cond_earliest);
+         emit_insns_before (seq, if_info->jump);
 
          return TRUE;
        }
@@ -867,7 +867,7 @@ noce_try_store_flag_mask (if_info)
          if (seq_contains_jump (seq))
            return FALSE;
 
-         emit_insns_before (seq, if_info->cond_earliest);
+         emit_insns_before (seq, if_info->jump);
 
          return TRUE;
        }
@@ -962,7 +962,7 @@ noce_try_cmove (if_info)
 
          seq = get_insns ();
          end_sequence ();
-         emit_insns_before (seq, if_info->cond_earliest);
+         emit_insns_before (seq, if_info->jump);
          return TRUE;
        }
       else
@@ -1124,7 +1124,7 @@ noce_try_cmove_arith (if_info)
 
   tmp = get_insns ();
   end_sequence ();
-  emit_insns_before (tmp, if_info->cond_earliest);
+  emit_insns_before (tmp, if_info->jump);
   return TRUE;
 
  end_seq_and_fail:
@@ -1376,7 +1376,7 @@ noce_try_minmax (if_info)
   if (seq_contains_jump (seq))
     return FALSE;
 
-  emit_insns_before (seq, earliest);
+  emit_insns_before (seq, if_info->jump);
   if_info->cond = cond;
   if_info->cond_earliest = earliest;
 
@@ -1494,7 +1494,7 @@ noce_try_abs (if_info)
   if (seq_contains_jump (seq))
     return FALSE;
 
-  emit_insns_before (seq, earliest);
+  emit_insns_before (seq, if_info->jump);
   if_info->cond = cond;
   if_info->cond_earliest = earliest;
 
@@ -1753,7 +1753,7 @@ noce_process_if_block (test_bb, then_bb, else_bb, join_bb)
   if (insn_b && else_bb)
     delete_insn (insn_b);
 
-  /* The new insns will have been inserted before cond_earliest.  We should
+  /* The new insns will have been inserted just before the jump.  We should
      be able to remove the jump with impunity, but the condition itself may
      have been modified by gcse to be shared across basic blocks.  */
   delete_insn (jump);
diff --git a/gcc/testsuite/gcc.c-torture/execute/20020503-1.c b/gcc/testsuite/gcc.c-torture/execute/20020503-1.c
new file mode 100644 (file)
index 0000000..6d45ca0
--- /dev/null
@@ -0,0 +1,31 @@
+/* PR 6534 */
+/* GCSE unified the two i<0 tests, but if-conversion to ui=abs(i) 
+   insertted the code at the wrong place corrupting the i<0 test.  */
+
+void abort (void);
+static char *
+inttostr (long i, char buf[128])
+{
+  unsigned long ui = i;
+  char *p = buf + 127;
+  *p = '\0';
+  if (i < 0)
+    ui = -ui;
+  do
+    *--p = '0' + ui % 10;
+  while ((ui /= 10) != 0);
+  if (i < 0)
+    *--p = '-';
+  return p;
+}
+
+int
+main ()
+{
+  char buf[128], *p;
+
+  p = inttostr (-1, buf);
+  if (*p != '-')
+    abort ();
+  return 0;
+}
This page took 0.087479 seconds and 5 git commands to generate.