diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33029bb6b15..6e53aa4d951 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2002-05-03 Richard Henderson + + 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 * 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 2002-05-02 Aldy Hernandez - * 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 diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index f46a6cf7cc1..e8c2b5f89b9 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -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 index 00000000000..6d45ca09af0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20020503-1.c @@ -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; +}