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 d103ae6..0287d52 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 cd4b625..c269ca6 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 3c20875..8d739b5 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 } } */