This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix tree-opt/29439, ICE with -fwrapv and Ada and VRP
- From: Andrew Pinski <pinskia at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 28 Oct 2006 17:18:38 -0700
- Subject: [PATCH] Fix tree-opt/29439, ICE with -fwrapv and Ada and VRP
The problem here is that IV-opts detection for multiply overflow is
wrong. It tries to see if (a*b)/b == a but the code does MAX/b == a
which can never be true and not does not do what the comment about the
code says it does:
/* Checking for multiplication overflow is done by dividing the
output of the multiplication by the first input of the
multiplication. If the result of that division operation is
not equal to the second input of the multiplication, then the
multiplication overflowed. */
This patch fixes problem by using the result (a*b) instead which makes
the code do what the comment says and fixes the ICE with subtypes that
have variables as MIN/MAX.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* tree-vrp.c (vrp_int_const_binop): Use the correct tree when
checking for overflow.
Index: tree-vrp.c
===================================================================
--- tree-vrp.c (revision 117752)
+++ tree-vrp.c (working copy)
@@ -1177,7 +1177,7 @@ vrp_int_const_binop (enum tree_code code
else if (code == MULT_EXPR && !integer_zerop (val1))
{
tree tmp = int_const_binop (TRUNC_DIV_EXPR,
- TYPE_MAX_VALUE (TREE_TYPE (val1)),
+ res,
val1, 0);
int check = compare_values (tmp, val2);