This is the mail archive of the
mailing list for the GCC project.
[PATCH] Check -fwrapv before simplifying A - B < 0 to A < B
- From: Bonzini <bonzini at gnu dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 1 Mar 2004 04:44:15 -0500
- Subject: [PATCH] Check -fwrapv before simplifying A - B < 0 to A < B
This optimization is already disabled for unsigned comparison.
2004-02-18 Paolo Bonzini <firstname.lastname@example.org>
* simplify-rtx.c (simplify_relational_operation): If
flag_wrapv is set, do not move terms between the two
side of a relational operator.
--- gcc-old/simplify-rtx.c 2004-02-10 13:11:37.000000000 +0100
+++ gcc/simplify-rtx.c 2004-02-10 13:15:15.000000000 +0100
@@ -2524,9 +2524,10 @@
If CODE is an unsigned comparison, then we can never do this optimization,
because it gives an incorrect result if the subtraction wraps around zero.
ANSI C defines unsigned operations such that they never overflow, and
- thus such cases can not be ignored. */
+ thus such cases can not be ignored; but we cannot do it even for
+ signed comparisons for languages such as Java, so test flag_wrapv. */
- if (INTEGRAL_MODE_P (mode) && trueop1 != const0_rtx
+ if (!flag_wrapv && INTEGRAL_MODE_P (mode) && trueop1 != const0_rtx
&& ! ((GET_CODE (op0) == REG || GET_CODE (trueop0) == CONST_INT)
&& (GET_CODE (op1) == REG || GET_CODE (trueop1) == CONST_INT))
&& 0 != (tem = simplify_binary_operation (MINUS, mode, op0, op1))