re PR middle-end/77594 (double computation for __builtin_sub_overflow (0, ...))
authorJakub Jelinek <jakub@redhat.com>
Fri, 16 Sep 2016 07:09:27 +0000 (09:09 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 16 Sep 2016 07:09:27 +0000 (09:09 +0200)
PR middle-end/77594
* internal-fn.c (expand_arith_overflow) <case MINUS_EXPR>: Don't fall
through into expand_addsub_overflow after expand_neg_overflow.

* gcc.target/i386/pr77594.c: New test.

Co-Authored-By: Eric Botcazou <ebotcazou@adacore.com>
From-SVN: r240173

gcc/ChangeLog
gcc/internal-fn.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr77594.c [new file with mode: 0644]

index d103ae65fe40908e9820c9bfd47817fd5e74b097..0287d52c5e0368565758189d4c13f4a7cef70245 100644 (file)
@@ -1,3 +1,10 @@
+2016-09-16  Jakub Jelinek  <jakub@redhat.com>
+           Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR middle-end/77594
+       * internal-fn.c (expand_arith_overflow) <case MINUS_EXPR>: Don't fall
+       through into expand_addsub_overflow after expand_neg_overflow.
+
 2016-09-15  David Malcolm  <dmalcolm@redhat.com>
 
        * diagnostic-show-locus.c
index cd4b6254c81eaaddf08f784f811d0a79272689b0..c269ca6b940cfda11c6be9b01e4c84fdaa70d512 100644 (file)
@@ -1833,7 +1833,10 @@ expand_arith_overflow (enum tree_code code, gimple *stmt)
            {
            case MINUS_EXPR:
              if (integer_zerop (arg0) && !unsr_p)
-               expand_neg_overflow (loc, lhs, arg1, false);
+               {
+                 expand_neg_overflow (loc, lhs, arg1, false);
+                 return;
+               }
              /* FALLTHRU */
            case PLUS_EXPR:
              expand_addsub_overflow (loc, code, lhs, arg0, arg1,
index 3c2087528a9d7b4c2875909b86fbd360a5834ecf..8d739b5a7596fd0abb63b5ae556b4a1d688eaccd 100644 (file)
@@ -1,3 +1,9 @@
+2016-09-16  Jakub Jelinek  <jakub@redhat.com>
+           Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR middle-end/77594
+       * gcc.target/i386/pr77594.c: New test.
+
 2016-09-15  Louis Krupp  <louis.krupp@zoho.com>
 
        PR fortran/69963
diff --git a/gcc/testsuite/gcc.target/i386/pr77594.c b/gcc/testsuite/gcc.target/i386/pr77594.c
new file mode 100644 (file)
index 0000000..96c51fd
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR middle-end/77594 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+int
+foo (int a, int *b)
+{
+  return __builtin_sub_overflow (0, a, b);
+}
+
+/* { dg-final { scan-assembler-times "\tjn?o\t" 1 } } */