aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-12-02 13:09:13 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-12-02 13:09:13 +0000
commitac19a30334bd8d3638079c8a54d1473218744fa1 (patch)
treee93c79ca1d83d42d8787ee2ad6aae7d61c2e12ff /gcc
parent88936a2bfd6b33aa5fa3c01cbe973c362d4a06c2 (diff)
downloadgcc-ac19a30334bd8d3638079c8a54d1473218744fa1.zip
gcc-ac19a30334bd8d3638079c8a54d1473218744fa1.tar.gz
gcc-ac19a30334bd8d3638079c8a54d1473218744fa1.tar.bz2
match.pd: When combining divisions exclude the degenerate case involving INT_MIN from...
2014-12-02 Richard Biener <rguenther@suse.de> * match.pd: When combining divisions exclude the degenerate case involving INT_MIN from overflow handling. * gcc.dg/torture/20141202-1.c: New testcase. From-SVN: r218269
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/match.pd4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/torture/20141202-1.c15
4 files changed, 27 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 09a5416..2bf3bce 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-02 Richard Biener <rguenther@suse.de>
+
+ * match.pd: When combining divisions exclude the degenerate
+ case involving INT_MIN from overflow handling.
+
2014-12-02 Wilco Dijkstra <wilco.dijkstra@arm.com>
* ira-costs.c (scan_one_insn): Improve spill cost adjustment.
diff --git a/gcc/match.pd b/gcc/match.pd
index b36aa2f..6c225b4 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -140,7 +140,9 @@ along with GCC; see the file COPYING3. If not see
}
(if (!overflow_p)
(div @0 { wide_int_to_tree (type, mul); }))
- (if (overflow_p)
+ (if (overflow_p
+ && (TYPE_UNSIGNED (type)
+ || mul != wi::min_value (TYPE_PRECISION (type), SIGNED)))
{ build_zero_cst (type); }))))
/* Optimize A / A to 1.0 if we don't care about
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1410f10..00da0bd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-12-02 Richard Biener <rguenther@suse.de>
+
+ * gcc.dg/torture/20141202-1.c: New testcase.
+
2014-12-02 H.J. Lu <hongjiu.lu@intel.com>
PR ipa/63814
diff --git a/gcc/testsuite/gcc.dg/torture/20141202-1.c b/gcc/testsuite/gcc.dg/torture/20141202-1.c
new file mode 100644
index 0000000..0ea6369
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/20141202-1.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+int foo (int x)
+{
+ return (x / 2) / ((-__INT_MAX__ - 1) / -2);
+}
+
+int main()
+{
+ if (foo (- __INT_MAX__ - 1) != -1)
+ abort ();
+ return 0;
+}