This is the mail archive of the
`gcc-patches@gcc.gnu.org`
mailing list for the GCC project.

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |

*To*: rth at cygnus dot com, gcc-patches at gcc dot gnu dot org*Subject*: simplify_comparison tweak*From*: Jan Hubicka <jh at suse dot cz>*Date*: Tue, 12 Sep 2000 01:08:41 +0200

Hi WHen simplify_comparison is converting a+b <-> 0 to a <-> -b, it don't swap the operands, so neg appears as the second in pattern. When the a <-> -b is written by hand, it is swapped earlier, so opposite pattern appears. This patch fixes this by catching such cases in simplify_comparison and making canonicalization rules for comparisons same as we do use for commutatives. The patch depends on swap_commutative_operands patch, that in turn depends on the i386 string operations canonicalization fixes (since it makes validate_replace_regs to swap operands when result may be noncanonical, that makes integrate to fail substitute register to register in noncacnonical pattern). I may break the dependency chain eighter by copying the test here, or by avoidding the recog bits in swap_commutative_operands patch. Honza Tue Sep 12 01:04:15 MET DST 2000 Jan Hubicka <jh@suse.cz> * combine.c (simplify_comparison): Take care to swap operands when needed. *** combine.c.old Mon Sep 11 18:03:22 2000 --- combine.c Mon Sep 11 22:42:33 2000 *************** simplify_comparison (code, pop0, pop1) *** 10342,10348 **** { op0 = XEXP (op0, 0); op1 = tem; ! continue; } /* If just looking at the sign bit, reverse the sense of the --- 10350,10356 ---- { op0 = XEXP (op0, 0); op1 = tem; ! goto canonize; } /* If just looking at the sign bit, reverse the sense of the *************** simplify_comparison (code, pop0, pop1) *** 10362,10368 **** { op0 = XEXP (op0, 0); op1 = tem; ! continue; } /* The remaining cases only apply to comparisons with zero. */ --- 10370,10376 ---- { op0 = XEXP (op0, 0); op1 = tem; ! goto canonize; } /* The remaining cases only apply to comparisons with zero. */ *************** simplify_comparison (code, pop0, pop1) *** 10402,10408 **** { op0 = XEXP (op0, 0); op1 = tem; ! continue; } /* If we are doing a < 0 or >= 0 comparison, it means we are testing --- 10410,10416 ---- { op0 = XEXP (op0, 0); op1 = tem; ! goto canonize; } /* If we are doing a < 0 or >= 0 comparison, it means we are testing *************** simplify_comparison (code, pop0, pop1) *** 10502,10516 **** case PLUS: /* (eq (plus X A) B) -> (eq X (minus B A)). We can only do ! this for equality comparisons due to pathological cases involving ! overflows. */ ! if (equality_comparison_p && 0 != (tem = simplify_binary_operation (MINUS, mode, op1, XEXP (op0, 1)))) { op0 = XEXP (op0, 0); op1 = tem; ! continue; } /* (plus (abs X) (const_int -1)) is < 0 if and only if X == 0. */ --- 10510,10526 ---- case PLUS: /* (eq (plus X A) B) -> (eq X (minus B A)). We can only do ! this for equality comparisons or values where we are sure ! that overflow may not happen. */ ! if ((equality_comparison_p ! || (num_sign_bit_copies (op0, mode) >= 2 ! && num_sign_bit_copies (op1, mode) >= 2)) && 0 != (tem = simplify_binary_operation (MINUS, mode, op1, XEXP (op0, 1)))) { op0 = XEXP (op0, 0); op1 = tem; ! goto canonize; } /* (plus (abs X) (const_int -1)) is < 0 if and only if X == 0. */ *************** simplify_comparison (code, pop0, pop1) *** 10531,10554 **** /* (eq (minus A B) C) -> (eq A (plus B C)) or (eq B (minus A C)), whichever simplifies. We can only do ! this for equality comparisons due to pathological cases involving ! overflows. */ if (equality_comparison_p ! && 0 != (tem = simplify_binary_operation (PLUS, mode, ! XEXP (op0, 1), op1))) { ! op0 = XEXP (op0, 0); ! op1 = tem; ! continue; ! } ! if (equality_comparison_p ! && 0 != (tem = simplify_binary_operation (MINUS, mode, ! XEXP (op0, 0), op1))) ! { ! op0 = XEXP (op0, 1); ! op1 = tem; ! continue; } /* The sign bit of (minus (ashiftrt X C) X), where C is the number --- 10541,10567 ---- /* (eq (minus A B) C) -> (eq A (plus B C)) or (eq B (minus A C)), whichever simplifies. We can only do ! this for equality comparisons or values where we are sure ! that overflow may not happen. */ if (equality_comparison_p ! || (num_sign_bit_copies (op0, mode) >= 2 ! && num_sign_bit_copies (op1, mode) >= 2)) { ! if (0 != (tem = simplify_binary_operation (PLUS, mode, ! XEXP (op0, 1), op1))) ! { ! op0 = XEXP (op0, 0); ! op1 = tem; ! goto canonize; ! } ! if (0 != (tem = simplify_binary_operation (MINUS, mode, ! XEXP (op0, 0), op1))) ! { ! op0 = XEXP (op0, 1); ! op1 = tem; ! goto canonize; ! } } /* The sign bit of (minus (ashiftrt X C) X), where C is the number *************** simplify_comparison (code, pop0, pop1) *** 10573,10579 **** { op0 = XEXP (op0, 0); op1 = tem; ! continue; } break; --- 10586,10592 ---- { op0 = XEXP (op0, 0); op1 = tem; ! goto canonize; } break; *************** simplify_comparison (code, pop0, pop1) *** 10610,10616 **** code = (code == LT || code == NE ? GET_CODE (op0) : reverse_condition (GET_CODE (op0))); op0 = tem, op1 = tem1; ! continue; } break; --- 10623,10629 ---- code = (code == LT || code == NE ? GET_CODE (op0) : reverse_condition (GET_CODE (op0))); op0 = tem, op1 = tem1; ! goto canonize; } break; *************** simplify_comparison (code, pop0, pop1) *** 10891,10896 **** --- 10904,10916 ---- } break; + canonize: + /* Canonize the operands. */ + if (swap_commutative_operands_p (op0, op1)) + { + tem = op0, op0 = op1, op1 = tem; + code = swap_condition (code); + } } /* Now make any compound operations involved in this comparison. Then,

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |