This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/31058] overflow warnings should not be enabled with -Wall
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Mar 2007 16:38:51 -0000
- Subject: [Bug middle-end/31058] overflow warnings should not be enabled with -Wall
- References: <bug-31058-12049@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #22 from rguenth at gcc dot gnu dot org 2007-03-08 16:38 -------
Note that one reason we do not optimize the dead code is the stupidity of VRP
dealing with the IL in the second pass. While in the first pass VRP figures
out a range of [0,5] for w_6 in
<bb 2>:
uexp.1_1 = uexp;
if (uexp.1_1 <= 159) goto <L0>; else goto <L1>;
<L0>:;
D.1770_3 = 160 - uexp.1_1;
D.1778_5 = D.1770_3 >> 5;
w_6 = (int) D.1778_5;
in the second VRP pass we get w_6 as varying... Appearantly the difference
starts with the
D.1778_5 = D.1770_3 >> 5;
statement where the first pass gets [0, 5] and the second [0, +INF]. It
looks like this is because the first pass sees
D.1778_5 = D.1770_3 / 32;
instead. It seems to be the VRP pass itself calling fold_stmt on the
division and producing the (unhandled) division. Fixing that makes the
warning (and the dead code) go away.
Index: gcc/tree-vrp.c
===================================================================
*** gcc/tree-vrp.c (revision 122691)
--- gcc/tree-vrp.c (working copy)
*************** extract_range_from_binary_expr (value_ra
*** 1568,1573 ****
--- 1568,1574 ----
&& code != CEIL_DIV_EXPR
&& code != EXACT_DIV_EXPR
&& code != ROUND_DIV_EXPR
+ && code != RSHIFT_EXPR
&& code != MIN_EXPR
&& code != MAX_EXPR
&& code != BIT_AND_EXPR
*************** extract_range_from_binary_expr (value_ra
*** 1735,1741 ****
|| code == FLOOR_DIV_EXPR
|| code == CEIL_DIV_EXPR
|| code == EXACT_DIV_EXPR
! || code == ROUND_DIV_EXPR)
{
tree val[4];
size_t i;
--- 1736,1743 ----
|| code == FLOOR_DIV_EXPR
|| code == CEIL_DIV_EXPR
|| code == EXACT_DIV_EXPR
! || code == ROUND_DIV_EXPR
! || code == RSHIFT_EXPR)
{
tree val[4];
size_t i;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31058