diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-04-06 10:36:57 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-04-06 10:36:57 +0000 |
commit | 30806cf18c1416546da47e9e4fdb23692b37a73c (patch) | |
tree | 96cc7ac4d17db40c43940ec6cf151a6e463c1c0a | |
parent | a1b9762a00210b64f90bc9e4599d336fea68b574 (diff) | |
download | gcc-30806cf18c1416546da47e9e4fdb23692b37a73c.tar.gz |
2010-04-06 Richard Guenther <rguenther@suse.de>
PR middle-end/43661
* fold-const.c (fold_comparison): Handle X * 0 CMP 0.
* gcc.c-torture/compile/pr43661.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157984 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr43661.c | 5 |
4 files changed, 18 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 13485d69cac..f181b059c70 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-04-06 Richard Guenther <rguenther@suse.de> + + PR middle-end/43661 + * fold-const.c (fold_comparison): Handle X * 0 CMP 0. + 2010-04-05 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> * doc/invoke.texi (Optimize Options): Document that LTO diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8dd68c2540f..e79d934243d 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9576,7 +9576,9 @@ fold_comparison (location_t loc, enum tree_code code, tree type, tree variable1 = TREE_OPERAND (arg0, 0); enum tree_code cmp_code = code; - gcc_assert (!integer_zerop (const1)); + /* Handle unfolded multiplication by zero. */ + if (integer_zerop (const1)) + return fold_build2_loc (loc, cmp_code, type, const1, const2); fold_overflow_warning (("assuming signed overflow does not occur when " "eliminating multiplication in comparison " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ffc51285e1b..9df8395fabe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-06 Richard Guenther <rguenther@suse.de> + + PR middle-end/43661 + * gcc.c-torture/compile/pr43661.c: New testcase. + 2010-04-06 Jakub Jelinek <jakub@redhat.com> * gcc.target/s390/stackcheck1.c: Add dg-warning. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr43661.c b/gcc/testsuite/gcc.c-torture/compile/pr43661.c new file mode 100644 index 00000000000..1337e1df33b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr43661.c @@ -0,0 +1,5 @@ +int +func (int x) +{ + return 0 ? (unsigned short) (0 ? : 1 * (signed char) (x ^ x) >= 0) : 1; +} |