OSDN Git Service

2010-04-06 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Apr 2010 10:36:57 +0000 (10:36 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Apr 2010 10:36:57 +0000 (10:36 +0000)
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

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr43661.c [new file with mode: 0644]

index 13485d6..f181b05 100644 (file)
@@ -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
index 8dd68c2..e79d934 100644 (file)
@@ -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 "
index ffc5128..9df8395 100644 (file)
@@ -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 (file)
index 0000000..1337e1d
--- /dev/null
@@ -0,0 +1,5 @@
+int
+func (int x)
+{
+  return 0 ? (unsigned short) (0 ? : 1 * (signed char) (x ^ x) >= 0) : 1;
+}