This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix pr21085
- From: ja2morri at csclub dot uwaterloo dot ca (James A. Morrison)
- To: gcc-patches at gcc dot gnu dot org
- Date: 18 Apr 2005 22:35:19 -0400
- Subject: [committed] Fix pr21085
Hi,
This bug where TRUNC_MOD_EXPR was trying to simplify X % INT_MIN to
X % INT_MIN where INT_MIN was acheived through overflow. The reason this
wasn't caught by the sign_bit_p check was that sign_bit_p returns NULL for
expressions that have overflowed. This patch has been bootstrapped and
regtested on ia64-linux and preapproved by Roger in the PR.
--
Thanks,
Jim
http://www.csclub.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim
2005-04-18 James A. Morrison <phython@gcc.gnu.org>
PR tree-optimization/21085
* fold-const (fold_binary): Don't change X % -C to X % C if C has
overflowed.
Index: fold-const.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.561
diff -u -p -r1.561 fold-const.c
--- fold-const.c 16 Apr 2005 14:07:28 -0000 1.561
+++ fold-const.c 18 Apr 2005 20:13:08 -0000
@@ -8500,6 +8523,7 @@ fold_binary (enum tree_code code, tree t
if (code == TRUNC_MOD_EXPR
&& !TYPE_UNSIGNED (type)
&& TREE_CODE (arg1) == INTEGER_CST
+ && !TREE_CONSTANT_OVERFLOW (arg1)
&& TREE_INT_CST_HIGH (arg1) < 0
&& !flag_trapv
/* Avoid this transformation if C is INT_MIN, i.e. C == -C. */