]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/77594 (double computation for __builtin_sub_overflow ...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:23:20 +0000 (09:23 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:23:20 +0000 (09:23 +0200)
Backported from mainline
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.

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

From-SVN: r248607

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

index 3fc433d85395b6100ef2fb8ca36a7e55f9f8274f..855c5a642c1ab4505f44e15a0355ef4d9ad4a8d6 100644 (file)
@@ -1,6 +1,13 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/68260
index e4028250c2acecb6387eefee44b56efdf3b404a5..2da980512fcb23355f7c102172497b8b06c4d2d4 100644 (file)
@@ -1786,7 +1786,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 468bd1d3a45dfd400c8849229198ae340b5f46d1..8618807b782c0eb2350779a1abfed3da42af0c0a 100644 (file)
@@ -1,6 +1,12 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/68260
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 } } */